:root {
  --bg: #0f1420;
  --card: #1a2133;
  --border: #2a3348;
  --text: #e6e9f0;
  --muted: #8891a7;
  --green: #2ecc71;
  --red: #e74c3c;
  --accent: #4a90e2;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6fb;
    --card: #ffffff;
    --border: #dde3ee;
    --text: #1a2133;
    --muted: #6b7386;
  }
}

* { box-sizing: border-box; }

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

header {
  padding: 2rem 1.5rem 1rem;
  text-align: center;
}

header h1 { margin: 0; font-size: 2rem; }
.subtitle { color: var(--muted); margin-top: 0.3rem; }

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
}

.card h2 {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.stats .label { display: block; color: var(--muted); font-size: 0.8rem; }
.stats .value { display: block; font-size: 1.3rem; font-weight: 600; margin-top: 0.2rem; }

#trade-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

#symbol-input, #qty-input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  font-size: 1rem;
}

#symbol-input { flex: 1 1 140px; text-transform: uppercase; }
#qty-input { flex: 0 1 140px; }

.quote { font-weight: 600; min-width: 90px; }

.trade-buttons { display: flex; gap: 0.5rem; width: 100%; }

button {
  flex: 1;
  border: none;
  border-radius: 8px;
  padding: 0.7rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  color: white;
}

.btn-buy { background: var(--green); }
.btn-sell { background: var(--red); }
button:hover { filter: brightness(1.1); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.message { min-height: 1.2rem; margin: 0.75rem 0 0; font-size: 0.9rem; }
.message.error { color: var(--red); }
.message.success { color: var(--green); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  text-align: left;
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow-x: auto;
}

th { color: var(--muted); font-weight: 500; }

.pl-positive { color: var(--green); }
.pl-negative { color: var(--red); }

#positions-card, #orders-card { overflow-x: auto; }

#watchlist-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

#watchlist-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.5rem 0.8rem;
  text-transform: uppercase;
}

#watchlist-form button {
  flex: 0 0 auto;
  background: var(--accent);
  padding: 0.5rem 1rem;
}

#watchlist-table tbody tr { cursor: pointer; }
#watchlist-table tbody tr:hover { background: rgba(74, 144, 226, 0.08); }

.remove-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  padding: 0 0.3rem;
  flex: none;
  width: auto;
}
.remove-btn:hover { color: var(--red); }

.chart-wrap { margin-top: 1.25rem; }
.chart-title { color: var(--muted); font-size: 0.9rem; margin: 0 0 0.5rem; }
