:root {
  --bg: #0b1020;
  --panel: #131a32;
  --panel-2: #1a2244;
  --text: #e7ecf5;
  --muted: #94a0c0;
  --line: #25304f;
  --accent: #5b8cff;
  --green: #2ecc71;
  --red: #ff5d6c;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  --radius: 12px;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Helvetica,
    Arial, sans-serif;
}
a {
  color: var(--accent);
}

header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #0e1430, #0b1020);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand h1 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0.3px;
}
.logo {
  font-size: 22px;
}

#nav-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
#nav-tabs button {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
}
#nav-tabs button:hover {
  color: var(--text);
}
#nav-tabs button.active {
  background: var(--panel-2);
  color: var(--text);
  border-color: var(--line);
}

.user-area {
  margin-left: auto;
}
#user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
#user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--panel-2);
}
#logout-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}

main {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 20px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  text-align: center;
  max-width: 520px;
  margin: 60px auto;
}
.card h2 {
  margin-top: 0;
}
.muted {
  color: var(--muted);
}
.tiny {
  font-size: 12px;
}

#g-signin {
  display: flex;
  justify-content: center;
  margin: 18px 0 8px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.toolbar h2 {
  margin: 0;
  font-size: 18px;
}
.toolbar-right {
  margin-left: auto;
  display: flex;
  gap: 8px;
}
#filter,
#add-symbol {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 10px;
  font: inherit;
  min-width: 220px;
}
#refresh-btn,
#add-btn {
  background: var(--accent);
  border: none;
  color: white;
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  font: inherit;
}
#refresh-btn {
  min-width: 36px;
  padding: 7px 10px;
}

#watchlist-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.status {
  color: var(--muted);
  margin: 6px 0 12px;
  min-height: 18px;
}

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  box-shadow: var(--shadow);
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}
th,
td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th {
  background: var(--panel-2);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
th.num,
td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
tbody tr:hover {
  background: rgba(91, 140, 255, 0.06);
}
.up {
  color: var(--green);
}
.down {
  color: var(--red);
}
.row-action {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 12px;
}
.row-action:hover {
  color: var(--text);
}

footer {
  text-align: center;
  color: var(--muted);
  padding: 30px 20px;
  font-size: 12px;
}

/* ---- Modal --------------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 9, 22, 0.7);
  backdrop-filter: blur(4px);
}
.modal-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  width: min(960px, 96vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-close {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  padding: 0 6px;
}
.modal-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}
.modal-stats strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.modal-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px 0;
  border-bottom: 1px solid var(--line);
}
.modal-tabs .tab {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  font: inherit;
}
.modal-tabs .tab.active {
  background: var(--panel-2);
  color: var(--text);
}
.modal-body {
  padding: 14px 16px 18px;
  overflow: auto;
  min-height: 480px;
}
.modal-body .pane[hidden] { display: none; }
#tradingview-host { height: 480px; }
#moomoo-frame {
  width: 100%;
  height: 480px;
  border: 0;
  border-radius: 8px;
  background: var(--panel-2);
}
.history-table { font-size: 12px; font-variant-numeric: tabular-nums; }
.history-table table { min-width: auto; }
td.symbol-cell { cursor: pointer; }
td.symbol-cell:hover strong {
  color: var(--accent);
  text-decoration: underline;
}

@media (max-width: 720px) {
  header {
    flex-wrap: wrap;
  }
  #nav-tabs {
    order: 3;
    width: 100%;
  }
  .user-area {
    margin-left: auto;
  }
}
