:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --border: #e2e5e9;
  --text: #14181f;
  --text-dim: #5b6472;
  --accent: #2563eb;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f14;
    --surface: #141a22;
    --border: #232b36;
    --text: #e8edf3;
    --text-dim: #8b96a5;
    --accent: #5b8def;
    --green: #34d399;
    --red: #f87171;
    --amber: #fbbf24;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: 16px;
  padding-bottom: 48px;
}

.app { max-width: 640px; margin: 0 auto; }

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 8px;
}

header.topbar h1 { font-size: 1.15rem; margin: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-live { background: rgba(220, 38, 38, 0.15); color: var(--red); }
.badge-paper { background: rgba(37, 99, 235, 0.15); color: var(--accent); }
.badge-active { background: rgba(22, 163, 74, 0.15); color: var(--green); }
.badge-paused { background: rgba(217, 119, 6, 0.15); color: var(--amber); }
.badge-buy { background: rgba(22, 163, 74, 0.15); color: var(--green); }
.badge-sell { background: rgba(220, 38, 38, 0.15); color: var(--red); }
.badge-hold { background: rgba(139, 150, 165, 0.15); color: var(--text-dim); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
}

.card h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin: 0 0 10px;
}

.stat-row { display: flex; justify-content: space-between; margin-bottom: 8px; }
.stat-row:last-child { margin-bottom: 0; }
.stat-label { color: var(--text-dim); font-size: 0.9rem; }
.stat-value { font-weight: 600; font-size: 0.95rem; }

.pnl-pos { color: var(--green); }
.pnl-neg { color: var(--red); }

table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 500; font-size: 0.75rem; text-transform: uppercase; }
tr:last-child td { border-bottom: none; }

.empty { color: var(--text-dim); font-size: 0.85rem; padding: 4px 0; }

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

button {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  flex: 1;
  min-width: 120px;
}

button.primary { background: var(--accent); color: white; }
button.danger { background: var(--red); color: white; }
button.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }

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

.footer-note {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.75rem;
  margin-top: 8px;
}

.error-banner {
  background: rgba(220, 38, 38, 0.12);
  color: var(--red);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.85rem;
  margin-bottom: 14px;
}

.login-form { display: flex; flex-direction: column; gap: 10px; }
.login-form input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
}

[hidden] { display: none !important; }
