:root {
	--bg: #0b1220;
	--panel: #121a2b;
	--panel-2: #1a2741;
	--text: #e5e7eb;
	--muted: #9ca3af;
	--border: #26354d;
	--primary: #2563eb;
	--danger: #ef4444;
	--success: #22c55e;
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	font-family: Inter, Segoe UI, Arial, sans-serif;
	color: var(--text);
	background: radial-gradient(circle at top right, #1b2950 0%, var(--bg) 50%);
}

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

.small-text {
	font-size: 0.95rem;
}

.small-note {
	margin-top: 14px;
	font-size: 0.9rem;
}

.mt-10 {
	margin-top: 10px;
}

.mt-12 {
	margin-top: 12px;
}

.mt-16 {
	margin-top: 16px;
}

.auth-gate {
	min-height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
}

.auth-gate-inner {
	width: 100%;
	max-width: 460px;
	background: linear-gradient(180deg, var(--panel-2) 0%, var(--panel) 100%);
	border: 1px solid var(--border);
	border-radius: 14px;
	padding: 20px;
}

.auth-brand {
	text-align: center;
	margin-bottom: 12px;
}

.auth-brand h1 {
	margin: 0 0 6px;
	font-size: 1.4rem;
}

.logo-icon {
	width: 42px;
	height: 42px;
	margin: 0 auto 10px;
	border-radius: 10px;
	background: linear-gradient(135deg, #60a5fa 0%, #2563eb 100%);
}

.auth-tabs {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px;
	margin-bottom: 14px;
}

.auth-tab {
	border: 1px solid var(--border);
	border-radius: 10px;
	background: #13203a;
	color: var(--text);
	padding: 10px;
	cursor: pointer;
}

.auth-tab.active {
	background: var(--primary);
	border-color: var(--primary);
}

.auth-form {
	display: grid;
	gap: 10px;
}

.input-group {
	display: grid;
	gap: 6px;
}

label {
	font-size: 0.86rem;
	color: #cfd8e3;
}

.input-dark {
	width: 100%;
	border: 1px solid #334155;
	background: #0f172a;
	color: var(--text);
	border-radius: 10px;
	padding: 10px;
	font-size: 0.95rem;
}

.btn {
	border: none;
	border-radius: 10px;
	padding: 10px 12px;
	cursor: pointer;
	text-decoration: none;
	color: #fff;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	font-size: 0.9rem;
}

.btn-primary {
	background: var(--primary);
}

.btn-outline {
	background: #1f2e4a;
	border: 1px solid var(--border);
}

.btn-block {
	width: 100%;
}

.btn.small {
	padding: 8px 10px;
	font-size: 0.82rem;
}

.auth-error {
	color: #fca5a5;
	margin: 0;
	font-size: 0.88rem;
}

.auth-success {
	color: #86efac;
	margin: 0;
	font-size: 0.88rem;
}

.row-actions {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
}

.app-container {
	min-height: 100vh;
	display: grid;
	grid-template-columns: 230px 1fr;
}

.sidebar {
	border-right: 1px solid var(--border);
	background: #101827;
	padding: 16px 12px;
}

.logo-container {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 16px;
}

.logo-container h1 {
	font-size: 0.95rem;
	margin: 0;
}

.nav-links {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: 8px;
}

.nav-links li {
	padding: 10px;
	border-radius: 8px;
	border: 1px solid var(--border);
	background: #18243a;
	font-size: 0.9rem;
	cursor: pointer;
}

.nav-links li.active {
	border-color: var(--primary);
	background: #1d3158;
}

.main-content {
	display: grid;
	grid-template-rows: 64px 1fr;
}

.top-bar {
	border-bottom: 1px solid var(--border);
	display: flex;
	align-items: center;
	justify-content: flex-end;
	padding: 0 16px;
	background: #0f172a;
}

.controls {
	display: flex;
	align-items: center;
	gap: 10px;
}

.mode-toggle {
	display: flex;
	align-items: center;
	gap: 8px;
}

.switch {
	position: relative;
	display: inline-block;
	width: 44px;
	height: 24px;
}

.switch input {
	opacity: 0;
	width: 0;
	height: 0;
}

.slider {
	position: absolute;
	cursor: pointer;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background-color: #334155;
	transition: 0.2s;
}

.slider:before {
	position: absolute;
	content: "";
	height: 18px;
	width: 18px;
	left: 3px;
	bottom: 3px;
	background-color: #ffffff;
	transition: 0.2s;
}

input:checked + .slider {
	background-color: var(--success);
}

input:checked + .slider:before {
	transform: translateX(20px);
}

.slider.round {
	border-radius: 24px;
}

.slider.round:before {
	border-radius: 50%;
}

.badge {
	padding: 4px 8px;
	border-radius: 999px;
	font-size: 0.75rem;
	font-weight: 700;
	border: 1px solid transparent;
}

.paper-badge {
	color: #93c5fd;
	background: #1e3a8a33;
	border-color: #3b82f6;
}

.live-badge {
	color: #bbf7d0;
	background: #14532d66;
	border-color: #22c55e;
}

.label {
	font-size: 0.84rem;
	font-weight: 700;
}

.tab-content {
	padding: 16px;
	display: none;
}

.tab-content.active {
	display: block;
}

.card {
	border: 1px solid var(--border);
	border-radius: 12px;
	background: linear-gradient(180deg, var(--panel-2) 0%, var(--panel) 100%);
	padding: 16px;
}

.card h3 {
	margin: 0;
}

.list-wrap {
	display: grid;
	gap: 10px;
	margin-top: 12px;
}

.row-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 10px;
	padding: 10px;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: #13203a;
}

.row-item.stacked {
	display: grid;
	justify-content: stretch;
}

.row-title {
	font-weight: 600;
	font-size: 0.95rem;
}

.row-edit {
	display: flex;
	gap: 8px;
	align-items: center;
	flex-wrap: wrap;
}

.small-input {
	width: 120px;
}

.profile-form {
	margin-top: 12px;
}

/* ── Paper Trades Table ─────────────────── */
.pt-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.82rem;
}
.pt-table th,
.pt-table td {
	padding: 8px 10px;
	text-align: left;
	border-bottom: 1px solid var(--border);
	white-space: nowrap;
}
.pt-table th {
	cursor: pointer;
	user-select: none;
	color: var(--text-secondary);
	font-weight: 600;
	position: sticky;
	top: 0;
	background: var(--bg-card);
}
.pt-table th:hover {
	color: var(--accent);
}
.pt-table th .sort-arrow {
	margin-left: 4px;
	font-size: 0.7rem;
}
.pt-table tbody tr:hover {
	background: rgba(99, 102, 241, 0.07);
}
.pt-badge {
	display: inline-block;
	padding: 2px 8px;
	border-radius: 6px;
	font-size: 0.75rem;
	font-weight: 600;
}
.pt-badge.open { background: rgba(34,197,94,0.15); color: #22c55e; }
.pt-badge.sl-hit { background: rgba(239,68,68,0.15); color: #ef4444; }
.pt-badge.target-hit { background: rgba(59,130,246,0.15); color: #3b82f6; }
.pt-badge.ce { background: rgba(34,197,94,0.12); color: #22c55e; }
.pt-badge.pe { background: rgba(239,68,68,0.12); color: #ef4444; }

/* ── Backtest ─────────────────── */
.bt-form {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
	gap: 12px 20px;
	align-items: end;
}
.bt-form .input-row {
	display: flex;
	flex-direction: column;
	gap: 4px;
}
.bt-form .input-row label {
	font-size: 0.8rem;
	color: var(--text-secondary);
}
.bt-run-params {
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 12px 16px;
	background: var(--bg-card);
}
.bt-params-grid {
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 8px 24px;
	align-items: baseline;
}
.bt-param-label {
	font-size: 0.8rem;
	color: var(--text-secondary);
}
.bt-param-value {
	font-size: 0.95rem;
	font-weight: 500;
}
.mb-8 { margin-bottom: 8px; }
.mb-6 { margin-bottom: 6px; }
.bt-gates { }
.bt-gates-grid {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 20px;
	align-items: center;
}
.bt-gate-cb {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 0.9rem;
	cursor: pointer;
}
.bt-gate-cb input { margin: 0; }
.bt-stats {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 12px;
}
.bt-stat-card {
	background: var(--bg-card);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 12px 16px;
	display: flex;
	flex-direction: column;
	gap: 4px;
}
.bt-stat-label {
	font-size: 0.75rem;
	color: var(--text-secondary);
}
.bt-stat-value {
	font-size: 1.1rem;
	font-weight: 600;
}
.bt-chart-wrap {
	max-width: 700px;
	min-height: 200px;
}
.bt-trade-table-wrap {
	overflow-x: auto;
}
.bt-trade-table {
	margin-top: 8px;
}
.bt-pnl-win { color: #22c55e; font-weight: 600; }
.bt-pnl-loss { color: #ef4444; font-weight: 600; }

.bt-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 8px 0;
}
.bt-loading-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: bt-spin 0.8s linear infinite;
}
.bt-loading-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
}
@keyframes bt-spin {
  to { transform: rotate(360deg); }
}
#bt-fetch-btn:disabled,
#bt-run-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.plan-card {
  background: var(--card-bg, #1a2236);
  border: 1px solid var(--border, #2a3a5c);
  border-radius: 12px;
  padding: 20px 16px;
  width: 160px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
  text-align: center;
}
.plan-card:hover {
  border-color: #4c8ef7;
  transform: translateY(-2px);
}
.plan-card.current-plan {
  border-color: #4c8ef7;
  background: rgba(76, 142, 247, 0.08);
}
.plan-card.current-plan .plan-badge {
  display: inline-block;
}
.plan-badge {
  display: none;
  font-size: 10px;
  background: #4c8ef7;
  color: #fff;
  border-radius: 4px;
  padding: 2px 6px;
  margin-bottom: 8px;
}
.plan-name {
  font-size: 18px;
  font-weight: 700;
  text-transform: capitalize;
  margin-bottom: 4px;
}
.plan-price {
  font-size: 22px;
  font-weight: 700;
  color: #4c8ef7;
  margin-bottom: 4px;
}
.plan-desc {
  font-size: 11px;
  color: #8892a4;
  margin-bottom: 12px;
  min-height: 32px;
}
.plan-select-btn {
  width: 100%;
}

/* ── Broker styles ── */
.broker-card {
  display: inline-block;
  background: var(--card-bg, #1a2236);
  border: 1px solid #2a3a5c;
  border-radius: 8px;
  padding: 12px 20px;
  font-weight: 600;
}
.broker-client { font-weight: 400; color: #8892a4; font-size: 13px; }
.broker-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-bg, #1a2236);
  border: 1px solid #2a3a5c;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 8px;
}
.broker-row-name { font-size: 14px; }
.broker-dropdown-wrap { position: relative; }
.broker-dropdown-menu {
  position: absolute;
  right: 0;
  top: 110%;
  background: #1e2d45;
  border: 1px solid #2a3a5c;
  border-radius: 8px;
  min-width: 160px;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.broker-menu-item {
  padding: 10px 16px;
  cursor: pointer;
  font-size: 13px;
}
.broker-menu-item:hover { background: rgba(76,142,247,0.1); }
.broker-menu-item.danger { color: #fc8181; }
.broker-menu-item.danger:hover { background: rgba(252,129,129,0.1); }
