:root {
  --primary: #1a1a2e;
  --primary-light: #16213e;
  --accent: #e94560;
  --accent-light: #ff6b6b;
  --success: #00d9a5;
  --warning: #ffc107;
  --bg: #0f0f23;
  --bg-card: #1a1a2e;
  --bg-card-hover: #252542;
  --text: #eaeaea;
  --text-muted: #8b8b9e;
  --border: #2a2a42;
  --buy: #ff4757;
  --sell: #2ed573;
}

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  margin: 0;
  padding: 0;
  background: linear-gradient(135deg, var(--bg) 0%, #1a1a3a 100%);
  color: var(--text);
  min-height: 100vh;
}

/* Header */
.header {
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
  padding: 1.5rem 2rem 1rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.header-content h1 {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 700;
  background: linear-gradient(90deg, #fff, var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-subtitle {
  margin: 0.3rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.main-nav {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.nav-btn {
  padding: 0.6rem 1.5rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  transition: all 0.2s ease;
  border-bottom: 3px solid transparent;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.nav-btn.active {
  color: var(--accent);
  border-bottom: 3px solid var(--accent);
  background: rgba(233, 69, 96, 0.1);
}

/* Sections */
.section {
  display: none;
  padding: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
  animation: fadeIn 0.3s ease;
}

.section.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.3);
}

.card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.4rem;
  color: var(--text);
}

.card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  color: var(--text);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.update-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0.3rem 0;
}

/* Controls */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1.5rem;
  margin: 1rem 0;
  align-items: center;
}

.control-block {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.control-block label {
  color: var(--text-muted);
}

.checkbox-group {
  margin-top: 0.5rem;
}

#stockInput {
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  min-width: 100px;
  font-size: 0.9rem;
}

#stockInput:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.2);
}

#loadBtn {
  padding: 0.5rem 1.2rem;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: white;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: transform 0.2s, box-shadow 0.2s;
}

#loadBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(233, 69, 96, 0.4);
}

#loadBtn:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

select {
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
}

input[type="checkbox"] {
  accent-color: var(--accent);
}

/* Layout */
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.col {
  flex: 1 1 400px;
}

.chart-col {
  flex: 1.2;
}

.table-col {
  flex: 0.8;
}

/* Tables */
.table-container {
  max-height: 400px;
  overflow-y: auto;
  border-radius: 8px;
}

.table-container.large {
  max-height: 500px;
}

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

th,
td {
  padding: 0.5rem 0.6rem;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 500;
  position: sticky;
  top: 0;
  z-index: 10;
}

th:nth-child(1),
td:nth-child(1),
th:nth-child(2),
td:nth-child(2) {
  text-align: left;
}

tbody tr {
  transition: background 0.15s;
}

tbody tr:hover {
  background: var(--bg-card-hover);
  cursor: pointer;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  font-size: 0.7rem;
  background: rgba(233, 69, 96, 0.2);
  color: var(--accent);
  margin-right: 0.3rem;
}

/* Buy/Sell Colors */
.net-positive,
.buy-text {
  color: var(--buy);
  font-weight: 600;
}

.net-negative,
.sell-text {
  color: var(--sell);
  font-weight: 600;
}

/* Broker Cards */
.broker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.broker-card {
  background: var(--bg);
  border-radius: 12px;
  padding: 1rem;
  border: 1px solid var(--border);
  transition: transform 0.2s, border-color 0.2s;
}

.broker-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.broker-card h4 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.broker-card .trades-list {
  font-size: 0.8rem;
  line-height: 1.6;
}

.target-list {
  font-size: 0.8rem;
  background: var(--bg);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  display: inline-block;
}

/* Footer */
.footer {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

.footer a {
  color: var(--accent);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
  .header {
    padding: 1rem;
  }

  .header-content h1 {
    font-size: 1.4rem;
  }

  .section {
    padding: 1rem;
  }

  .nav-btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
  }

  .col {
    flex: 1 1 100%;
  }

  .card {
    padding: 1rem;
  }
}