/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0f14;
  --surface: #161b25;
  --surface2: #1e2637;
  --border: #2a3448;
  --accent: #f7931a;
  --accent-dim: rgba(247,147,26,0.15);
  --green: #22c55e;
  --red: #ef4444;
  --text: #e2e8f0;
  --text-dim: #8494a8;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius: 8px;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ===== Login ===== */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 0%, rgba(247,147,26,0.08) 0%, var(--bg) 60%);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.login-logo h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.login-subtitle {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 28px;
}

/* ===== Forms ===== */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"],
select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 12px;
  font-size: 14px;
  font-family: var(--font);
  transition: border-color .2s;
  outline: none;
}

input:focus, select:focus {
  border-color: var(--accent);
}

select option { background: var(--surface); }

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity .2s;
}

.btn-primary:hover { opacity: 0.88; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font);
  transition: border-color .2s;
}
.btn-secondary:hover { border-color: var(--accent); }

.error-msg {
  color: var(--red);
  font-size: 13px;
  margin-bottom: 10px;
}

/* ===== App Shell ===== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
}

.app-header .logo span { color: var(--accent); }

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-dim);
  font-size: 13px;
}

/* ===== Dashboard Layout ===== */
.dashboard {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: calc(100vh - 53px);
  overflow: hidden;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.main {
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ===== Sidebar Controls ===== */
.sidebar-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.leverage-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.leverage-row input[type="number"] {
  flex: 1;
  text-align: right;
}

.leverage-unit {
  font-weight: 700;
  color: var(--accent);
  min-width: 12px;
}

.run-btn {
  width: 100%;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity .2s;
}
.run-btn:hover { opacity: 0.88; }
.run-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0,0,0,0.3);
  border-top-color: #000;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-dim);
}

/* ===== Results Table ===== */
.table-wrap {
  overflow-x: auto;
  max-height: 380px;
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--surface2);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
thead th:first-child { text-align: left; }
thead th:hover { color: var(--text); }

tbody tr {
  border-bottom: 1px solid rgba(42,52,72,0.5);
  cursor: pointer;
  transition: background .1s;
}
tbody tr:hover { background: var(--surface2); }
tbody tr.selected { background: var(--accent-dim); }

tbody td {
  padding: 7px 12px;
  text-align: right;
  color: var(--text);
  white-space: nowrap;
}
tbody td:first-child { text-align: left; font-weight: 600; }

.tag-liq {
  display: inline-block;
  background: rgba(239,68,68,0.2);
  color: var(--red);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
}

.tag-best {
  display: inline-block;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  margin-left: 4px;
}

/* Return color gradient helper classes — applied via JS */
.ret-pos-hi  { color: #22c55e; }
.ret-pos-mid { color: #86efac; }
.ret-pos-low { color: #bbf7d0; }
.ret-neg-low { color: #fca5a5; }
.ret-neg-mid { color: #f87171; }
.ret-neg-hi  { color: #ef4444; }

/* ===== Chart ===== */
.chart-container {
  position: relative;
  height: 320px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 280px;
  color: var(--text-dim);
  gap: 8px;
}

.empty-state svg { opacity: 0.3; }
.empty-state p { font-size: 13px; }

/* ===== Status Bar ===== */
.status-bar {
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.status-bar span { display: flex; align-items: center; gap: 4px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.dot.red { background: var(--red); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .dashboard {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: auto;
  }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); }
}
