/* ============================================================
   TOKENS
   ============================================================ */
:root {
  --bg: #0a0f1c;
  --bg-alt: #0d1424;
  --panel: #121a2c;
  --panel-2: #16203570;
  --border: #223154;
  --text: #e9edf6;
  --text-muted: #8493b3;
  --text-dim: #566285;
  --green: #17d980;
  --green-dim: #17d98022;
  --red: #ff4d5e;
  --red-dim: #ff4d5e22;
  --amber: #f2a93b;
  --amber-dim: #f2a93b22;
  --blue: #5b8cff;

  --font-display: "Space Grotesk", "Be Vietnam Pro", sans-serif;
  --font-body: "Be Vietnam Pro", "Inter", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --radius: 10px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: radial-gradient(1200px 600px at 15% -10%, #101c33 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

::selection { background: var(--amber-dim); color: var(--amber); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   TICKER TAPE (signature element)
   ============================================================ */
.ticker-tape {
  background: #060a14;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  white-space: nowrap;
  position: relative;
  height: 34px;
  display: flex;
  align-items: center;
}
.ticker-tape .live-dot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--red);
  border-right: 1px solid var(--border);
  height: 100%;
}
.live-dot::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--red);
  animation: pulse 1.4s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.25} }

.ticker-track {
  display: inline-flex;
  gap: 28px;
  padding-left: 20px;
  animation: scroll-left 32s linear infinite;
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.ticker-track:hover { animation-play-state: paused; }
@keyframes scroll-left {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
.ticker-item .sym { color: var(--text-muted); margin-right: 6px; }
.ticker-item .up { color: var(--green); }
.ticker-item .down { color: var(--red); }

/* ============================================================
   HEADER
   ============================================================ */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand .mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.01em;
}
.brand .mark span { color: var(--amber); }
.brand .sub { font-size: 12px; color: var(--text-dim); }

.header-right { display: flex; align-items: center; gap: 14px; }
.mock-badge {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 4px 8px;
  border-radius: 20px;
  border: 1px solid var(--amber);
  color: var(--amber);
  letter-spacing: 0.05em;
}
.clock { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }

/* ============================================================
   INDEX STRIP
   ============================================================ */
.index-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  padding: 16px 28px 4px;
}
.index-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.index-card .code { font-size: 11px; color: var(--text-dim); letter-spacing: 0.06em; }
.index-card .val { font-family: var(--font-mono); font-size: 22px; font-weight: 600; margin-top: 2px; }
.index-card .chg { font-family: var(--font-mono); font-size: 12.5px; margin-top: 2px; }

/* ============================================================
   MAIN GRID
   ============================================================ */
.main-grid {
  display: grid;
  grid-template-columns: 240px minmax(0,1fr) 300px;
  gap: 16px;
  padding: 16px 28px;
  align-items: start;
}
@media (max-width: 1080px) {
  .main-grid { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.panel-head h2 {
  font-family: var(--font-display);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0;
}
.panel-body { padding: 14px 16px; }

/* Watchlist */
.watchlist-add {
  display: flex; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.watchlist-add input {
  flex: 1; background: var(--bg-alt); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 6px 8px; font-family: var(--font-mono); font-size: 12px; text-transform: uppercase;
}
.watchlist-add button, .btn {
  background: var(--amber); color: #1a1204; border: none; border-radius: 6px;
  font-weight: 600; font-size: 12px; padding: 6px 10px; cursor: pointer;
}
.watchlist-add button:hover, .btn:hover { filter: brightness(1.08); }

.watch-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border);
}
.watch-item:last-child { border-bottom: none; }
.watch-item:hover { background: var(--panel-2); }
.watch-item.active { background: var(--amber-dim); border-left: 3px solid var(--amber); }
.watch-item .sym { font-weight: 600; font-size: 13.5px; }
.watch-item .name { font-size: 10.5px; color: var(--text-dim); }
.watch-item .right { text-align: right; font-family: var(--font-mono); }
.watch-item .price { font-size: 13px; }
.watch-item .chg { font-size: 11px; }
.watch-item .rm { color: var(--text-dim); font-size: 14px; padding-left: 8px; }
.watch-item .rm:hover { color: var(--red); }

.up { color: var(--green); }
.down { color: var(--red); }
.flat { color: var(--text-muted); }

/* Chart / fundamentals */
.symbol-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.symbol-title .sym { font-family: var(--font-display); font-size: 22px; font-weight: 700; }
.symbol-title .name { color: var(--text-muted); font-size: 13px; }
.symbol-title .price { font-family: var(--font-mono); font-size: 20px; margin-left: auto; }
.range-tabs { display: flex; gap: 6px; margin: 12px 0; }
.range-tabs button {
  background: transparent; border: 1px solid var(--border); color: var(--text-muted);
  padding: 4px 10px; border-radius: 20px; font-size: 11.5px; cursor: pointer; font-family: var(--font-mono);
}
.range-tabs button.active { background: var(--amber); color: #1a1204; border-color: var(--amber); font-weight: 600; }
.chart-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 10px 0; font-size: 12px; }
.chk { display: flex; align-items: center; gap: 4px; color: var(--text-muted); cursor: pointer; user-select: none; }
.sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.btn-outline {
  background: transparent; border: 1px solid var(--border); color: var(--text-muted);
  padding: 4px 10px; border-radius: 20px; font-size: 11.5px; cursor: pointer;
}
.btn-outline.active { background: var(--amber); color: #1a1204; border-color: var(--amber); font-weight: 600; }
.chart-stack { position: relative; height: 260px; margin-top: 6px; }
.chart-wrap { height: 260px; }
.trend-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: auto; cursor: default; }
.chart-wrap-rsi { height: 90px; margin-top: 4px; }

.fund-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 10px; margin-top: 16px;
}
.fund-cell { background: var(--bg-alt); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.fund-cell .label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; }
.fund-cell .value { font-family: var(--font-mono); font-size: 15px; margin-top: 3px; }

/* News */
.news-item { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.news-item:last-child { border-bottom: none; }
.news-item .meta { font-size: 10.5px; color: var(--text-dim); font-family: var(--font-mono); display:flex; gap:8px; }
.news-item .meta .tag { color: var(--amber); border: 1px solid var(--amber); border-radius: 10px; padding: 0 6px; }
.news-item .title { font-size: 13px; margin-top: 4px; line-height: 1.4; }
.news-item .title a { text-decoration: none; }
.news-item .title a:hover { color: var(--amber); }

/* ============================================================
   PORTFOLIO / TRANSACTION HISTORY
   ============================================================ */
.portfolio-section { padding: 4px 28px 28px; }
.portfolio-grid { display: grid; grid-template-columns: 1.1fr 1.4fr; gap: 16px; }
@media (max-width: 1080px) { .portfolio-grid { grid-template-columns: 1fr; } }

.tx-form { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tx-form label { font-size: 11px; color: var(--text-dim); display: block; margin-bottom: 4px; }
.tx-form input, .tx-form select {
  width: 100%; background: var(--bg-alt); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 8px 10px; font-size: 13px; font-family: var(--font-mono);
}
.tx-form .full { grid-column: 1 / -1; }
.tx-form .btn-submit {
  grid-column: 1 / -1; margin-top: 4px;
}

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 500; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; }
td.num, th.num { text-align: right; font-family: var(--font-mono); }
tr:hover td { background: var(--panel-2); }
.pill { padding: 2px 8px; border-radius: 20px; font-size: 10.5px; font-weight: 600; }
.pill.buy { background: var(--green-dim); color: var(--green); }
.pill.sell { background: var(--red-dim); color: var(--red); }
.del-btn { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 13px; }
.del-btn:hover { color: var(--red); }

.holdings-summary { display: flex; gap: 20px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.holdings-summary .stat .label { font-size: 10.5px; color: var(--text-dim); }
.holdings-summary .stat .val { font-family: var(--font-mono); font-size: 17px; margin-top: 2px; }

.empty-state { padding: 24px; text-align: center; color: var(--text-dim); font-size: 12.5px; }

.app-footer {
  padding: 18px 28px 32px;
  color: var(--text-dim);
  font-size: 11.5px;
  border-top: 1px solid var(--border);
}
.app-footer code { color: var(--amber); }

/* ---- SSI account panel ---- */
.account-actions { display: flex; align-items: center; gap: 10px; }
.account-status {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}
.account-status.up { color: var(--up); }
.account-status.down { color: var(--down); }
