/* VI Watchlist — shared design system (dark, matches CCAQR/VI Radar)
   Edit tokens here once; every page follows. */

:root {
  --bg: #0b0d10;
  --panel: #14181d;
  --panel2: #1b2027;
  --text: #e6e8eb;
  --muted: #8a92a0;
  --muted2: #5b6472;
  --border: #232a32;
  --border2: #2d353f;
  --accent: #7ee787;   /* brand green */
  --pos: #3fb950;      /* upside / positive */
  --neg: #f85149;      /* downside / negative */
  --amber: #d29922;
  --purple: #a371f7;
  --radius: 14px;
  --maxw: 1160px;
  --font: 'IBM Plex Sans Thai', -apple-system, system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
.mono { font-family: var(--mono); }

/* ---------- Top nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(11,13,16,0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; gap: 18px;
  padding: 12px 18px;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; letter-spacing: .2px; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.nav-links { display: flex; gap: 4px; margin-left: 8px; flex-wrap: wrap; }
.nav-links a {
  padding: 7px 12px; border-radius: 9px; color: var(--muted);
  font-size: 14px; font-weight: 500; transition: .12s;
}
.nav-links a:hover { color: var(--text); background: var(--panel); }
.nav-links a.active { color: var(--bg); background: var(--accent); }
.badge-private {
  margin-left: auto; font-family: var(--mono); font-size: 11px; letter-spacing: .5px;
  color: var(--amber); border: 1px solid var(--border2); padding: 4px 9px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.badge-private::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--amber); }

/* ---------- Layout ---------- */
.container { max-width: var(--maxw); margin: 0 auto; padding: 26px 18px 80px; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 22px; }
.page-head h1 { font-size: 24px; margin: 0; font-weight: 600; }
.page-head .sub { color: var(--muted); font-size: 13px; }
.section { margin-top: 30px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 0 0 12px; font-weight: 600; }

/* ---------- KPI tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 12px; }
.tile { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.tile .label { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.tile .value { font-family: var(--mono); font-size: 26px; font-weight: 500; }
.tile .sub { color: var(--muted2); font-size: 12px; margin-top: 4px; }

/* ---------- Cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; transition: .12s; }
.card:hover { border-color: var(--border2); background: var(--panel2); }
.card .tkr { font-family: var(--mono); font-weight: 600; font-size: 18px; }
.card .co { color: var(--muted); font-size: 12px; margin-top: 2px; height: 2.6em; overflow: hidden; }
.card .row { display: flex; justify-content: space-between; font-size: 13px; margin-top: 10px; }
.card .row .k { color: var(--muted); }
.card .row .v { font-family: var(--mono); }

/* ---------- Badges / values ---------- */
.star { color: var(--amber); }
.chip { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border2); color: var(--muted); font-family: var(--mono); }
.chip.top { color: var(--amber); border-color: rgba(210,153,34,.4); background: rgba(210,153,34,.08); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }

/* ---------- Table ---------- */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 760px; }
table.tbl th, table.tbl td { padding: 11px 12px; text-align: right; white-space: nowrap; }
table.tbl th:first-child, table.tbl td:first-child,
table.tbl th.l, table.tbl td.l { text-align: left; }
table.tbl thead th { background: var(--panel); color: var(--muted); font-weight: 600; font-size: 12px; position: sticky; top: 0; cursor: pointer; user-select: none; border-bottom: 1px solid var(--border); }
table.tbl thead th:hover { color: var(--text); }
table.tbl thead th .arw { color: var(--accent); }
table.tbl tbody tr { border-bottom: 1px solid var(--border); cursor: pointer; }
table.tbl tbody tr:last-child { border-bottom: none; }
table.tbl tbody tr:hover { background: var(--panel); }
table.tbl td.num { font-family: var(--mono); }

/* ---------- Full valuation table (Excel-style, two paths) ---------- */
table.tbl.wide { min-width: 1260px; font-size: 13px; }
table.tbl.wide th, table.tbl.wide td { padding: 8px 10px; }
th.grp { text-align: center; font-size: 11px; letter-spacing: .6px; border-bottom: 1px solid var(--border); }
/* two valuation paths, colour-separated: Core = blue, Premium = navy */
td.core { background: rgba(56,139,240,.09); }
td.prem { background: rgba(41,72,140,.24); }
table.tbl.wide thead th.core, table.tbl.wide th.grp.core { background: #152a44; color: #cfe4ff; }
table.tbl.wide thead th.prem, table.tbl.wide th.grp.prem { background: #141f3d; color: #ccd6ff; }
th.bl, td.bl { border-left: 2px solid var(--border2); }

/* Freeze the header: the table gets its own scroll box; header sticks to its top */
.tbl-wrap.scrollbox { max-height: calc(100vh - 195px); min-height: 320px; overflow: auto; }
table.tbl.wide thead th { position: sticky; z-index: 6; background: var(--panel); cursor: default; }
table.tbl.wide thead tr:first-child th { top: 0; }
table.tbl.wide thead tr:nth-child(2) th { top: var(--h1, 29px); }
table.tbl.wide tr.group-band td { position: static; top: auto; }

/* pick sign glyph */
.psign { font-size: 13px; line-height: 1; }
.psign.pick-g { color: #d4a72c; font-size: 16px; }
.psign.pick-v { display:inline-flex;align-items:center;justify-content:center;width:15px;height:15px;border-radius:50%;background:#4f9a87;color:#fff;font-size:10px;font-weight:700; }
.psign.pick-r { color: var(--amber); }
.subtype { color: var(--muted2); font-size: 11px; }

/* live price */
.price-live { color: var(--text); }
.price-live .ld { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--pos); margin-right: 5px; vertical-align: 1px; }
.price-stale { color: var(--muted); }
table.tbl th.valuation-col, table.tbl td.valuation-col { border-left: 2px solid var(--border); background: rgba(139,148,158,.06); }
table.tbl th.live-col, table.tbl td.live-col { border-right: 2px solid rgba(63,185,80,.5); background: rgba(63,185,80,.09); }
table.tbl td.live-col { font-weight: 600; }
table.tbl td.live-col.pos { color: var(--pos); }
table.tbl td.live-col.neg { color: var(--neg); }
table.tbl td.live-col.flat { color: var(--text); }
.live-note { color: var(--muted2); font-size: 12px; display: flex; align-items: center; gap: 7px; }
.live-note .ld { width: 7px; height: 7px; border-radius: 50%; background: var(--pos); display: inline-block; }

/* ---------- Grouped watchlist (mimics teacher's colour bands) ---------- */
tr.group-band td {
  font-weight: 600; font-size: 12.5px; letter-spacing: .3px;
  padding: 7px 12px; text-transform: uppercase;
  position: sticky; top: 40px; z-index: 1;
}
tr.group-band .gcount { opacity: .8; font-weight: 500; font-family: var(--mono); }
td.accent { border-left: 3px solid var(--border2); }

/* pick badges (teacher's conviction codes) */
.pick { display: inline-block; font-size: 10.5px; font-family: var(--mono); padding: 1px 6px; border-radius: 999px; border: 1px solid transparent; vertical-align: middle; }
.pick-g { color: var(--pos); background: rgba(63,185,80,.14); border-color: rgba(63,185,80,.35); }
.pick-v { color: #58c8f0; background: rgba(0,176,240,.14); border-color: rgba(0,176,240,.35); }
.pick-r { color: var(--amber); background: rgba(210,153,34,.14); border-color: rgba(210,153,34,.35); }

.legend { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.legend .swatch { width: 11px; height: 11px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: -1px; }
.legend .item { display: inline-flex; align-items: center; }

/* ---------- Controls ---------- */
.controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.controls input[type=text], .controls select {
  background: var(--panel); border: 1px solid var(--border2); color: var(--text);
  border-radius: 10px; padding: 9px 12px; font-family: var(--font); font-size: 14px; outline: none;
}
.controls input[type=text] { min-width: 190px; }
.controls input:focus, .controls select:focus { border-color: var(--accent); }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; color: var(--muted); user-select: none; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }
.count { color: var(--muted); font-size: 13px; margin-left: auto; font-family: var(--mono); }

/* ---------- News feed ---------- */
.feed { display: flex; flex-direction: column; gap: 10px; }
.news { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; display: flex; gap: 12px; }
.news .sig { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; }
.sig.high { background: var(--neg); } .sig.medium { background: var(--amber); } .sig.low { background: var(--muted2); }
.news .body { flex: 1; min-width: 0; }
.news .title { font-weight: 600; font-size: 14px; }
.news .meta { color: var(--muted); font-size: 12px; margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.news .meta .tkr { font-family: var(--mono); color: var(--accent); }
.news .summary { color: var(--muted); font-size: 13px; margin-top: 6px; }
.news .src a { color: var(--accent); font-size: 12px; }
.empty { color: var(--muted2); font-size: 13px; padding: 20px; text-align: center; border: 1px dashed var(--border2); border-radius: 12px; }

/* ---------- Stock detail ---------- */
.val-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.val-item { background: var(--panel); padding: 15px 16px; }
.val-item .k { color: var(--muted); font-size: 12px; }
.val-item .v { font-family: var(--mono); font-size: 20px; margin-top: 5px; }
.note-block { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; color: var(--muted); font-size: 14px; }
.back { color: var(--muted); font-size: 13px; }
.back:hover { color: var(--text); }

/* ---------- Dropzone (uploads) ---------- */
.dropzone { border: 2px dashed var(--border2); border-radius: var(--radius); padding: 40px 20px; text-align: center; color: var(--muted); cursor: pointer; transition: .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--panel); color: var(--text); }
.btn { display: inline-flex; align-items: center; gap: 8px; background: var(--accent); color: var(--bg); border: none; border-radius: 10px; padding: 10px 16px; font-weight: 600; font-size: 14px; cursor: pointer; font-family: var(--font); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border2); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.info { background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 10px; padding: 14px 16px; font-size: 13.5px; color: var(--muted); }
.info b { color: var(--text); }

@media (max-width: 600px) {
  .page-head h1 { font-size: 20px; }
  .tile .value { font-size: 22px; }
  .nav-inner { gap: 10px; }
  .brand span.full { display: none; }
}
