:root {
  --bg: #0d1117;
  --panel: #131922;
  --panel-2: #18202b;
  --line: #243041;
  --text: #d6dde6;
  --muted: #8593a5;
  --accent: #4f9cf9;
  --up: #2ebd85;
  --down: #f0616d;
  --warn: #e3b341;
  --row-h: 24px;
  --font: 12.5px/1.35 "Inter", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.up { color: var(--up); } .down { color: var(--down); } .muted { color: var(--muted); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 10px; height: 44px;
  padding: 0 12px; background: #0a0e14; border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; letter-spacing: .3px; font-size: 15px; }
.brand span { color: var(--accent); font-weight: 500; margin-left: 4px; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.jump { position: relative; }
.jump input { width: 240px; padding: 6px 10px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); outline: none; }
.jump input:focus { border-color: var(--accent); }
.jump-list { position: absolute; top: 34px; left: 0; width: 360px; max-height: 360px; overflow: auto; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 8px 24px #0008; z-index: 60; }
.jump-list div { padding: 5px 10px; cursor: pointer; display: flex; gap: 8px; }
.jump-list div.active, .jump-list div:hover { background: #22304a; }
.jump-list b { min-width: 56px; }
.counts { color: var(--muted); } .counts b { color: var(--text); }
.spacer { flex: 1; }
.sync { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; max-width: 420px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sync .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--up); flex: none; }
.sync .dot.busy { background: var(--warn); animation: pulse 1s infinite alternate; }
.sync .dot.err { background: var(--down); }
@keyframes pulse { to { opacity: .35; } }
.btn { padding: 5px 10px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.sm { padding: 2px 7px; font-size: 11.5px; }
.btn.on { background: #1f3b63; border-color: var(--accent); }
.menu { position: relative; }
.dropdown { position: absolute; right: 0; top: 34px; min-width: 200px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px; z-index: 60; box-shadow: 0 8px 24px #0008; }
.dropdown button { display: block; width: 100%; text-align: left; padding: 6px 10px; background: none; border: 0; border-radius: 4px; cursor: pointer; }
.dropdown button:hover { background: #22304a; }
.dropdown small { color: var(--muted); display: block; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #1f3b63; padding: 8px 14px; border-radius: 6px; z-index: 100; }

/* ---------- grid + panels ---------- */
.grid-stack { background: var(--bg); }
.grid-stack-item-content { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; display: flex; flex-direction: column; overflow: hidden !important; }
.grid-stack > .grid-stack-item > .ui-resizable-se { filter: invert(.7); }
.panel-head { display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 8px; border-bottom: 1px solid var(--line);
  background: var(--panel-2); cursor: move; flex: none; user-select: none; }
.panel-head .title { font-weight: 600; white-space: nowrap; }
.panel-head .tools { display: flex; gap: 4px; align-items: center; margin-left: auto; cursor: default; flex-wrap: nowrap; overflow: hidden; }
.panel-head .x { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 15px; padding: 0 4px; }
.panel-head .x:hover { color: var(--down); }
.panel-head select, .panel-head input { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 2px 4px; font-size: 11.5px; }
.panel-body { flex: 1; min-height: 0; overflow: auto; position: relative; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.seg button { background: none; border: 0; padding: 2px 8px; cursor: pointer; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.seg button.on { background: #1f3b63; color: var(--text); }
.empty { padding: 18px; color: var(--muted); text-align: center; }

/* ---------- screener table ---------- */
.vt { position: absolute; inset: 0; overflow: auto; }
.vt-head { position: sticky; top: 0; z-index: 3; display: flex; background: var(--panel-2); border-bottom: 1px solid var(--line); width: max-content; min-width: 100%; }
.vt-head div { padding: 5px 6px; color: var(--muted); font-size: 11.5px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: none; }
.vt-head div:hover { color: var(--text); }
.vt-head div.sorted { color: var(--accent); }
.vt-row { position: absolute; left: 0; display: flex; height: var(--row-h); align-items: center; width: max-content; min-width: 100%; border-bottom: 1px solid #1b2430; cursor: pointer; }
.vt-row:hover { background: #18222f; }
.vt-row.sel { background: #1d3150; }
.vt-row div { padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: none; }
.vt .r { text-align: right; }
.vt .sticky { position: sticky; left: 0; background: inherit; z-index: 2; }
.vt-head .sticky { background: var(--panel-2); }
.vt-row .sticky { background: var(--panel); }
.vt-row.sel .sticky { background: #1d3150; }
.vt-row:hover .sticky { background: #18222f; }
.tk { font-weight: 600; }
.star { color: var(--muted); margin-right: 4px; cursor: pointer; }
.star.on { color: var(--warn); }
.rs { display: inline-block; min-width: 26px; text-align: center; border-radius: 4px; padding: 0 3px; font-weight: 600; }
.colpick { max-height: 340px; overflow: auto; width: 280px; }
.colpick h5 { margin: 6px 6px 2px; color: var(--muted); font-weight: 600; }
.colpick label { display: block; padding: 2px 8px; cursor: pointer; }

/* ---------- filters ---------- */
.flt { padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.flt textarea, .flt input[type=text], .flt select { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 5px 7px; outline: none; }
.flt textarea { font-family: var(--mono); font-size: 12px; resize: vertical; min-height: 44px; }
.flt textarea.bad { border-color: var(--down); }
.flt .err { color: var(--down); font-size: 11.5px; }
.flt .hint { color: var(--muted); font-size: 11px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { background: #1f3b63; border-radius: 10px; padding: 1px 4px 1px 8px; font-size: 11.5px; display: inline-flex; gap: 4px; align-items: center; }
.chip button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0 3px; }
.sec { border: 1px solid var(--line); border-radius: 6px; }
.sec > summary { padding: 5px 8px; cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; }
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary .n { background: var(--accent); color: #fff; border-radius: 8px; padding: 0 6px; font-size: 11px; }
.sec[open] > summary { border-bottom: 1px solid var(--line); }
.fr { display: grid; grid-template-columns: 1fr 64px 64px 42px; gap: 4px; padding: 2px 8px; align-items: center; }
.fr .unit { color: var(--muted); font-size: 11px; white-space: nowrap; cursor: help; }
.fr .info { color: #56657a; font-style: normal; font-size: 10.5px; }
.fr input::placeholder { color: #4b5869; }
.fr:first-of-type { padding-top: 6px; } .fr:last-child { padding-bottom: 6px; }
.fr label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.fr.active label { color: var(--text); }
.fr input { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 2px 5px; font-family: var(--mono); font-size: 11.5px; outline: none; }
.fr input:focus { border-color: var(--accent); }
.cat { padding: 4px 8px 6px; }
.cat .cat-h { display: flex; justify-content: space-between; color: var(--muted); margin: 2px 0; }
.cat .opts { max-height: 150px; overflow: auto; border: 1px solid var(--line); border-radius: 4px; padding: 2px 0; background: var(--bg); }
.cat .opts label { display: flex; gap: 6px; padding: 1px 6px; cursor: pointer; white-space: nowrap; }
.cat .opts label span { margin-left: auto; color: var(--muted); }
.cat input[type=text] { margin-bottom: 3px; padding: 3px 6px; }
.presets { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---------- chart ---------- */
.chart-img { width: 100%; height: 100%; object-fit: contain; background: #fff; display: block; }
.chart-wrap { position: absolute; inset: 0; display: flex; flex-direction: column; }
.chart-wrap .cap { padding: 4px 8px; display: flex; gap: 10px; align-items: baseline; flex: none; }
.chart-wrap .cap b { font-size: 15px; }
.chart-wrap .area { flex: 1; min-height: 0; position: relative; }
.cgrid { display: grid; gap: 4px; padding: 4px; position: absolute; inset: 0; }
.cgrid .cell { background: #fff; border-radius: 4px; overflow: hidden; cursor: pointer; position: relative; border: 2px solid transparent; min-width: 0; min-height: 0; }
.cgrid .cell.sel { border-color: var(--accent); }
.cgrid .cell img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cgrid .cell .lbl { position: absolute; top: 2px; right: 4px; background: #0d1117cc; color: var(--text); padding: 0 5px; border-radius: 3px; font-size: 11px; }

/* ---------- lists (news, groups, detail) ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 5px 8px; border-bottom: 1px solid #1b2430; display: flex; gap: 8px; align-items: baseline; }
.list li .t { color: var(--muted); font-size: 11px; white-space: nowrap; min-width: 92px; font-family: var(--mono); }
.list li .tk { min-width: 48px; cursor: pointer; }
.list li .src { color: var(--muted); font-size: 11px; margin-left: auto; white-space: nowrap; }
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th, table.tbl td { padding: 4px 6px; border-bottom: 1px solid #1b2430; text-align: right; white-space: nowrap; }
table.tbl th { position: sticky; top: 0; background: var(--panel-2); color: var(--muted); font-weight: 500; cursor: pointer; z-index: 1; }
table.tbl th:first-child, table.tbl td:first-child { text-align: left; }
table.tbl tr.click { cursor: pointer; }
table.tbl tr.click:hover { background: #18222f; }
table.tbl tr.on { background: #1d3150; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0 12px; padding: 6px 8px; }
.kv div { display: flex; justify-content: space-between; border-bottom: 1px solid #1b2430; padding: 2px 0; gap: 6px; }
.kv div span:first-child { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kv div span:last-child { font-family: var(--mono); white-space: nowrap; }
.dhead { padding: 8px; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; border-bottom: 1px solid var(--line); }
.dhead .big { font-size: 18px; font-weight: 700; }
.dhead .co { color: var(--muted); }
.tag.pat { color: #9ec5ff; border-color: #2b4a73; }
.tag { background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 6px; font-size: 11px; color: var(--muted); }

/* ---------- breadth ---------- */
.br { padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.br .row { display: grid; grid-template-columns: 110px 1fr 54px; gap: 8px; align-items: center; }
.br .bar { height: 10px; background: #2a1820; border-radius: 5px; overflow: hidden; display: flex; }
.br .bar i { display: block; height: 100%; background: var(--up); }
.br .ad { display: flex; height: 16px; border-radius: 4px; overflow: hidden; }
.br .ad i { display: block; }
.br .hist { display: flex; align-items: flex-end; gap: 2px; height: 60px; }
.br .hist i { flex: 1; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 1px; }
.br .stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 12px; }
.br .stats div { display: flex; justify-content: space-between; }

/* ---------- watchlists ---------- */
.wl-bar { display: flex; gap: 4px; padding: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.wl-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.wl-add { display: flex; gap: 4px; padding: 6px; }
.wl-add input { flex: 1; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 3px 6px; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #2a3646; border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---- markets */
.market { background: var(--bg2, #161b22); color: var(--text); border: 1px solid #30363d; border-radius: 6px; padding: 4px 6px; font: inherit; max-width: 170px; }
/* ---- Pro chart */
.chart-wrap .stats { display: flex; gap: 12px; flex-wrap: wrap; padding: 0 8px 3px; font-size: 11px; flex: none; }
.chart-wrap .stats:empty { display: none; }
.chart-wrap .stats i { color: var(--muted); font-style: normal; }
.pro-cv { position: absolute; inset: 0; display: block; }
.cgrid.dark .cell { background: #0d1117; border-color: #21262d; }
.cgrid.dark .cell.sel { border-color: var(--accent); }
.cgrid .mini { position: absolute; inset: 0; }
.cgrid .mini .empty { padding: 6px; font-size: 11px; }
/* ---- heat map */
.hmap { position: absolute; inset: 0; overflow: hidden; }
.hm-sec { position: absolute; border: 1px solid #0d1117; box-sizing: border-box; }
.hm-sec > span { position: absolute; left: 3px; top: 0; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; overflow: hidden; max-width: calc(100% - 6px); }
.hm-cell { position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; cursor: pointer; color: #fff; text-shadow: 0 1px 1px #0008; line-height: 1.1; }
.hm-cell i { font-style: normal; font-size: 10px; opacity: .9; }
.hm-cell:hover, .hm-cell.sel { outline: 2px solid var(--accent); z-index: 1; }
.hm-tip { position: absolute; z-index: 5; pointer-events: none; background: #161b22f2; border: 1px solid #30363d; border-radius: 6px; padding: 6px 8px; font-size: 11px; max-width: 230px; }
/* ---- bubble */
.bub { position: absolute; inset: 0; bottom: 22px; }
.bub canvas { position: absolute; inset: 0; cursor: crosshair; }
.bub .legend { position: absolute; left: 0; right: 0; bottom: -22px; height: 22px; display: flex; gap: 10px; align-items: center; padding: 0 6px; font-size: 10px; overflow: hidden; white-space: nowrap; }
.bub .legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 3px; }
/* ---- market health */
.health { display: flex; flex-direction: column; height: 100%; }
.mh-chart { position: relative; height: 110px; flex: none; border-bottom: 1px solid #21262d; }
.mh-body { flex: 1; }
.posture { margin: 6px 8px; padding: 6px 10px; border-radius: 6px; font-weight: 600; background: #21262d; }
.posture.up { background: rgba(46,189,133,.18); color: #2ebd85; }
.posture.warn { background: rgba(227,179,65,.18); color: #e3b341; }
.posture.down { background: rgba(240,97,109,.18); color: #f0616d; }
/* ---- sizer */
.sizer { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; padding: 6px 8px; }
.sizer label { display: flex; flex-direction: column; font-size: 11px; color: var(--muted); gap: 2px; }
.sizer input, .sizer select { background: #0d1117; color: var(--text); border: 1px solid #30363d; border-radius: 4px; padding: 3px 5px; font: inherit; }
.sizer .out { grid-column: 1 / -1; }
.tbl th.hl { color: var(--accent); }
.tbl .tk { cursor: pointer; color: var(--accent); font-weight: 600; }

/* ---------- combo watchlists ---------- */
.wl-body { flex: 1; overflow: auto; }
.wl-bar .combo { border-style: dashed; }
.wl-bar .combo .wl-dot { width: 7px; height: 7px; margin-right: -2px; }
.tbl tr.sec td { text-align: left; background: #111821; color: var(--text); font-weight: 600; padding-top: 6px; position: sticky; top: 24px; z-index: 0; }
.tbl td.in { text-align: left; }
.tbl td.in .wl-dot { margin-right: 2px; }
.tbl .bell { font-size: 10px; margin-left: 4px; }
.combo-ed { display: flex; flex-direction: column; gap: 6px; padding: 8px; overflow: auto; }
.combo-ed .cn { background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 4px 6px; }
.combo-ed .opts { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.combo-ed label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; white-space: nowrap; }
.combo-ed .end, .al-row.end { display: flex; justify-content: flex-end; gap: 6px; }

/* ---------- alerts ---------- */
.bell-btn { position: relative; }
.badge { background: var(--down); color: #fff; border-radius: 8px; font-size: 10px; padding: 0 5px; margin-left: 4px; font-weight: 600; }
.bell-btn .badge { position: absolute; top: -5px; right: -6px; margin: 0; }
.al-form { padding: 8px; display: flex; flex-direction: column; gap: 6px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.al-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.al-row > label { width: 36px; color: var(--muted); }
.al-form select, .al-form input, .al-form textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 3px 6px; min-width: 0; }
.al-form input[data-f="ticker"] { width: 110px; text-transform: uppercase; }
.al-form input[data-f="note"] { flex: 1; }
.al-form textarea { font-family: var(--mono); font-size: 12px; min-height: 40px; resize: vertical; }
.al-prev { font-size: 11.5px; min-height: 15px; }
.al-prev.warn { color: var(--warn); }
.al-list { flex: 1; overflow: auto; }
.al-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-bottom: 1px solid #1b2430; }
.al-item .al-main { flex: 1; min-width: 0; cursor: default; }
.al-item .al-main[data-t] { cursor: pointer; }
.al-item .al-main > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.al-item .sm { font-size: 11px; }
.al-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--up); flex: none; box-shadow: 0 0 6px var(--up); }
.al-item.off .al-dot { background: var(--muted); box-shadow: none; }
.al-item.off .al-main { opacity: .6; }
.al-item.bad .al-dot { background: var(--down); box-shadow: none; }
.al-tools { display: flex; justify-content: space-between; align-items: center; padding: 4px 8px; }
.al-ev { padding: 6px 8px; border-bottom: 1px solid #1b2430; }
.al-ev .tks { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.chip-t { background: #1f3b63; border: 0; border-radius: 4px; padding: 0 6px; font-size: 11.5px; cursor: pointer; font-weight: 600; }
.chip-t:hover { background: #2b4f80; }
.alert-pop { position: fixed; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 6px; z-index: 120; }
.alert-pop .ap { position: relative; display: flex; flex-direction: column; gap: 2px; min-width: 240px; max-width: 340px; padding: 8px 26px 8px 12px;
  background: #1a2740; border: 1px solid var(--accent); border-left: 4px solid var(--warn); border-radius: 6px; box-shadow: 0 8px 24px #000a; cursor: pointer; animation: ap-in .2s ease-out; }
.alert-pop .ap small { color: var(--muted); }
.alert-pop .ap button { position: absolute; top: 4px; right: 4px; background: none; border: 0; color: var(--muted); cursor: pointer; }
@keyframes ap-in { from { transform: translateY(8px); opacity: 0; } }
.grid-stack-item.flash > .grid-stack-item-content { border-color: var(--accent); box-shadow: 0 0 0 2px #4f9cf966; transition: box-shadow .3s; }

/* ---------- journal ---------- */
.jr-form { padding: 8px; display: flex; flex-direction: column; gap: 6px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.jr-form input, .jr-form select, .jr-form textarea, .jr-d input, .jr-d select, .jr-d textarea, .jr-note-add textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 3px 6px; min-width: 0; }
.jr-form .al-row > label { width: auto; min-width: 36px; }
.jr-form input[data-f="ticker"] { width: 110px; text-transform: uppercase; }
.jr-form input[data-f="setup"] { flex: 1; }
.jr-form textarea, .jr-d textarea, .jr-note-add textarea { min-height: 44px; resize: vertical; width: 100%; }
.jr-hint { font-size: 11.5px; }
.jr-bar { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tbl.jr td.ell { max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
.tbl tr.jr-det > td { padding: 0; background: #0f151d; text-align: left; white-space: normal; }
.jr-d { padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.jr-d .al-row > label { width: auto; color: var(--muted); }
.jr-d input[data-e="setup"] { flex: 1; }
.jr-kv { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); }
.jr-kv b { color: var(--text); font-weight: 600; }
.jr-fills { max-width: 420px; }
.jr-fills td, .jr-fills th { padding: 2px 6px; }
.jr-snap { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.jr-stats { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.jr-sub { padding: 6px 8px 0; font-size: 11px; }
.jr-curve { height: 110px; margin: 0 8px 6px; position: relative; }
.jr-curve canvas { position: absolute; inset: 0; }
.jr-note-add { display: flex; gap: 6px; padding: 8px; align-items: flex-start; }
.jr-note-add button { white-space: nowrap; }
.jr-note { padding: 6px 8px; border-bottom: 1px solid #1b2430; }
.jr-note > div:first-child { display: flex; align-items: center; gap: 6px; font-size: 11px; }
.jr-note .x { margin-left: auto; }
.jr-note .txt { white-space: pre-wrap; margin-top: 3px; }

/* ---------- AI terminal ---------- */
.ai-main { position: absolute; inset: 0; display: flex; flex-direction: column; }
.ai-usage { font-size: 11px; }
.ai-log { flex: 1; overflow: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.ai-msg { max-width: 92%; padding: 7px 10px; border-radius: 8px; line-height: 1.45; }
.ai-msg.u { align-self: flex-end; background: #1f3b63; white-space: pre-wrap; }
.ai-msg.u small { display: block; font-size: 10.5px; text-align: right; }
.ai-msg.a { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line); }
.ai-msg.a p { margin: 0 0 6px; } .ai-msg.a ul { margin: 0 0 6px; padding-left: 18px; } .ai-msg.a li { margin: 2px 0; }
.ai-msg.a .ai-h { font-weight: 700; margin: 6px 0 4px; }
.ai-msg.a code { font-family: var(--mono); background: #0d1117; padding: 0 4px; border-radius: 3px; }
.ai-msg.a small { display: block; font-size: 10.5px; margin-top: 2px; }
.ai-msg.err { border-color: var(--down); color: #f5b3b9; }
.ai-msg.blk { border-color: var(--warn); }
.ai-msg .tk { color: var(--accent); cursor: pointer; font-weight: 600; }
.ai-msg.pending .dots::after { content: '…'; animation: pulse 1s infinite alternate; }
.ai-scan { display: flex; gap: 6px; align-items: center; margin: 4px 0; padding: 5px 6px; background: #0d1117; border: 1px solid var(--line); border-radius: 5px; }
.ai-scan code { flex: 1; white-space: pre-wrap; word-break: break-word; background: none !important; }
.ai-quick { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 8px 4px; }
.chip-q { background: none; border: 1px solid var(--line); border-radius: 12px; padding: 1px 9px; font-size: 11.5px; color: var(--muted); cursor: pointer; }
.chip-q:hover { border-color: var(--accent); color: var(--text); }
.ai-ctx { display: flex; flex-wrap: wrap; gap: 4px 10px; padding: 0 8px 4px; font-size: 11.5px; align-items: center; }
.ai-ctx label { display: inline-flex; gap: 3px; align-items: center; cursor: pointer; }
.ai-in { display: flex; gap: 6px; padding: 0 8px 4px; align-items: flex-end; }
.ai-in textarea { flex: 1; min-height: 42px; max-height: 140px; resize: vertical; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }
.ai-in textarea:focus { outline: none; border-color: var(--accent); }
.ai-send { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: 10.5px; }
.ai-foot { font-size: 10.5px; padding: 0 8px 6px; }
.ai-lock { padding: 18px; display: flex; justify-content: center; }
.ai-lock-in { max-width: 420px; display: flex; flex-direction: column; gap: 8px; }
.ai-lock-in p { margin: 0; line-height: 1.45; }
.ai-lock-in .warn { color: var(--warn); }
.ai-badge { font-size: 15px; font-weight: 700; }
.ai-badge span { font-size: 10.5px; font-weight: 600; color: #0d1117; background: var(--warn); border-radius: 4px; padding: 1px 6px; margin-left: 6px; vertical-align: 2px; }
.ai-keyrow { display: flex; gap: 6px; }
.ai-keyrow input { flex: 1; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 4px 8px; }

/* ---------- grouped + Panel menu, link groups ---------- */
#add-panel-menu { width: 560px; max-height: calc(100vh - 60px); overflow: auto; columns: 2; column-gap: 6px; padding: 6px; }
#add-panel-menu .grp { break-inside: avoid; margin-bottom: 6px; }
#add-panel-menu h6 { margin: 4px 10px 2px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--accent); }
#add-panel-menu .open { color: var(--up); font-size: 10px; }
.panel-head .lnk { background: none; border: 0; padding: 0 2px; cursor: pointer; display: flex; align-items: center; }
.panel-head .lnk i { width: 10px; height: 10px; border-radius: 3px; border: 1.5px dashed var(--muted); display: block; }
.panel-head .lnk.on i { border: 0; }
.link-menu { z-index: 200; }
.link-menu .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; border: 1px dashed var(--muted); margin-right: 8px; vertical-align: -1px; }
.link-menu small { display: inline !important; margin-left: 4px; }

/* ---------- flags + inline notes ---------- */
.flag { margin-left: 3px; font-size: 11px; cursor: pointer; }
.flag.off { color: var(--muted); opacity: 0; }
tr:hover .flag.off { opacity: .6; }
.nt { margin-left: 3px; font-size: 10px; }
.nt-btn { margin-left: 4px; font-size: 10.5px; cursor: pointer; color: var(--muted); opacity: 0; }
tr:hover .nt-btn, .nt-btn.has { opacity: 1; }
.wl-note { font-size: 11px; color: var(--muted); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; cursor: text; }
.wl-note-in { display: block; width: 100%; margin-top: 2px; font-size: 11px; background: var(--bg); border: 1px solid var(--accent); border-radius: 3px; padding: 1px 4px; }

/* ---------- My Screens ---------- */
.myscreens { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.myscreens .my-head { display: flex; align-items: center; gap: 4px; width: 100%; }
.myscreens .my-head .muted { font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; margin-right: auto; }
.myscreens .chip.my { cursor: pointer; background: var(--panel-2); border: 1px solid var(--line); }
.myscreens .chip.my.on { background: #1f3b63; border-color: var(--accent); }
.myscreens .sm { font-size: 11px; }

/* ---------- earnings, IPOs, portfolio ---------- */
.ec-tools { display: inline-flex; gap: 4px; align-items: center; }
.ec-day { margin-bottom: 4px; }
.ec-h { position: sticky; top: 0; z-index: 2; display: flex; gap: 8px; align-items: center; padding: 4px 8px; background: var(--panel-2); border-bottom: 1px solid var(--line); }
.ec-t th, .ec-t td { padding: 2px 6px; }
.ec-t .co { color: var(--muted); text-align: left !important; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.when { font-size: 9.5px; padding: 0 4px; border-radius: 3px; margin-left: 4px; color: var(--muted); border: 1px solid var(--line); }
.when.bmo { color: #e3b341; border-color: #5c4a1a; }
.when.amc { color: #79c0ff; border-color: #1f3b63; }
.tbl tr.on td { background: #1f3b6355; }
.chk { display: inline-flex; gap: 3px; align-items: center; font-size: 11.5px; cursor: pointer; }
.pad { padding: 6px 8px; }
.sm { font-size: 11px; }
.warn { color: var(--warn); }
.pf-kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; padding: 6px; }
.pf-kpis div { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; display: flex; flex-direction: column; }
.pf-kpis span { font-size: 10.5px; }
.pf-kpis b { font-size: 14px; }
.pf-sec { padding: 6px 8px; display: flex; flex-direction: column; gap: 3px; }
.pf-bar { display: grid; grid-template-columns: 130px 1fr 40px; gap: 6px; align-items: center; font-size: 11.5px; }
.pf-bar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-bar i { height: 8px; background: var(--accent); border-radius: 3px; display: block; }
.pf-bar b { text-align: right; font-weight: 500; }

/* ---------- chart drawings, compare, multi-chart ---------- */
.dbar { display: flex; gap: 6px; align-items: center; padding: 0 8px 3px; flex: none; flex-wrap: wrap; }
.dbar .dsel { display: inline-flex; gap: 4px; align-items: center; font-size: 11px; }
.dbar .cmpbox { margin-left: auto; display: inline-flex; gap: 2px; }
.dbar .cmp { width: 92px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; font-size: 11.5px; }
.dbar .cmp.bad { border-color: var(--down); }
.pro-cv:focus { outline: none; }
.mc { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 4px; }
.mc-cell { display: flex; flex-direction: column; min-width: 0; min-height: 0; border: 1px solid #21262d; border-radius: 4px; background: #0d1117; }
.mc-cell.sel { border-color: var(--accent); }
.mc .mc-cell[data-t] { cursor: default; }
.mc-h { font-size: 11px; padding: 2px 6px; flex: none; white-space: nowrap; overflow: hidden; }
.mc-c { flex: 1; min-height: 0; position: relative; }
.mc-c .empty { padding: 8px; font-size: 11px; }

/* ---------- P2: history charts, rotation, backtest, data panel, replay, AI tools ---------- */
.lc-wrap { position: absolute; inset: 0; display: flex; flex-direction: column; }
.lc { position: relative; flex: 1; min-height: 0; }
.rrg { position: absolute; inset: 0; display: flex; }
.rrg-c { position: relative; flex: 1; min-width: 0; }
.rrg-list { width: 230px; flex: none; overflow: auto; border-left: 1px solid var(--line); font-size: 11.5px; }
.rrg-list table.tbl td, .rrg-list table.tbl th { padding: 3px 5px; }
.tbl tr.off td { opacity: .38; }
.sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.bt { position: absolute; inset: 0; display: flex; flex-direction: column; overflow: auto; }
.bt-sum { flex: none; }
.bt-head { padding: 6px 8px 0; }
.bt-k { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.bt .bt-chart { position: relative; inset: auto; flex: none; height: 40%; min-height: 160px; }
.bt-tbl { flex: none; }
.bt-tk { text-align: left !important; white-space: normal !important; line-height: 1.7; }
.dp { padding: 6px 8px; font-size: 12px; }
.dp-head b { font-size: 15px; margin-right: 4px; }
.dp-rate { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; margin: 6px 0; }
.dp-rate div { border-radius: 5px; padding: 3px 4px; text-align: center; display: flex; flex-direction: column; background: var(--panel-2); }
.dp-rate span { font-size: 10px; opacity: .85; }
.dp-rate b { font-size: 14px; }
.dp-ev { display: flex; flex-direction: column; gap: 2px; margin: 4px 0; padding: 4px 6px; border: 1px solid var(--line); border-radius: 5px; font-size: 11.5px; }
.dp-note { margin: 4px 0; padding: 4px 6px; background: #1c1a10; border-radius: 5px; font-size: 11.5px; white-space: pre-wrap; }
.dp-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 10px; margin-top: 4px; }
.dp-grid div { display: flex; justify-content: space-between; gap: 6px; padding: 2px 0; border-bottom: 1px solid #1b2430; min-width: 0; }
.dp-grid span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dp-grid b { font-weight: 500; white-space: nowrap; }
.dp-ed-top { display: flex; gap: 4px; margin-bottom: 4px; }
.dp-ed-top .q { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 2px 6px; }
.dp-sec h6 { margin: 8px 0 2px; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.dp-sec label { display: inline-flex; gap: 3px; align-items: center; width: 50%; font-size: 11.5px; cursor: pointer; padding: 1px 0; }
.persel { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 2px 4px; font-size: 11.5px; }
.rbar { display: inline-flex; gap: 4px; align-items: center; }
.rbar .rp { display: inline-flex; gap: 3px; align-items: center; }
.rbar select { background: var(--bg); border: 1px solid var(--line); border-radius: 4px; font-size: 11px; }
.ai-tools { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 8px 4px; align-items: center; font-size: 11.5px; }
.ai-tools select { background: var(--bg); border: 1px solid var(--line); border-radius: 4px; font-size: 11.5px; max-width: 190px; }

/* ---------- P0: account, billing, sync, notifications ---------- */
.acct-btn { display: inline-flex; gap: 6px; align-items: center; max-width: 220px; overflow: hidden; white-space: nowrap; }
.acct-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--up); flex: none; }
.acct-dot.err { background: var(--down); }
.tier { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; padding: 1px 6px; border-radius: 8px; background: #2a3340; color: var(--muted); font-weight: 600; }
.tier.t-pro { background: #1f3b63; color: #9ccaff; }
.tier.t-premium { background: #3d3214; color: #f2cc60; }
.acct { padding: 8px 10px; font-size: 12.5px; }
.acct h4 { margin: 4px 0 8px; font-size: 14px; }
.acct h5 { margin: 0 0 5px; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.acct section { border-top: 1px solid var(--line); padding: 9px 0; }
.acct p { margin: 6px 0; }
.acct form { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; max-width: 340px; }
.acct-f { display: flex; flex-direction: column; gap: 3px; }
.acct-f span { color: var(--muted); font-size: 11.5px; }
.acct-f input, .acct-in { background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 6px 8px; color: var(--text); font-size: 12.5px; }
.acct-f input:focus, .acct-in:focus { border-color: var(--accent); outline: none; }
.acct-in { padding: 3px 6px; width: 190px; font-size: 11.5px; }
.acct-tabs { margin-bottom: 8px; }
.acct-msg { padding: 6px 8px; border-radius: 5px; background: #1f2a37; margin: 6px 0; }
.acct-msg.warn { background: rgba(240,97,109,.13); color: #ff9aa2; }
.acct-msg.ok { background: rgba(46,189,133,.13); color: #7ee0b5; }
.acct-why { margin-top: 12px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); }
.acct-why b { color: var(--text); }
.acct-why ul { margin: 4px 0 0; padding-left: 18px; }
.acct-head { margin-bottom: 6px; }
.acct-head b { font-size: 14px; }
.acct-row { display: flex; gap: 6px; align-items: center; justify-content: space-between; margin: 4px 0; }
.acct-row.wrap { flex-wrap: wrap; justify-content: flex-start; }
.acct-plans { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 6px 0; }
.acct-plans .btn, .acct-choice .btn { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 7px 9px; }
.acct-plans small, .acct-choice small { color: var(--muted); font-size: 11px; line-height: 1.35; }
.acct-plans .btn:disabled { opacity: .55; cursor: default; }
.acct-choice { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.acct-iv { margin: 4px 0; }
.acct-ch { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid #1b2430; }
.acct-ch:last-of-type { border-bottom: 0; }
.acct-ch-c { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.sw-tog { position: relative; display: inline-block; width: 30px; height: 17px; cursor: pointer; }
.sw-tog input { opacity: 0; width: 0; height: 0; position: absolute; }
.sw-tog i { position: absolute; inset: 0; background: #2a3340; border-radius: 10px; transition: background .15s; }
.sw-tog i::after { content: ''; position: absolute; left: 2px; top: 2px; width: 13px; height: 13px; border-radius: 50%; background: #c9d1d9; transition: transform .15s; }
.sw-tog input:checked + i { background: var(--accent); }
.sw-tog input:checked + i::after { transform: translateX(13px); }
.sw-tog input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.danger { background: rgba(240,97,109,.18); border-color: var(--down); color: #ffb3b9; }
.btn.danger-t { color: #ff9aa2; }
.grid-stack-item.flash > .grid-stack-item-content { box-shadow: 0 0 0 2px var(--accent); }
.reload-bar { position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%); z-index: 50; background: #1f3b63; color: var(--text); border: 1px solid var(--accent); border-radius: 18px; padding: 6px 14px; cursor: pointer; }

/* ---------- context menus (right-click) ---------- */
.ctx { position: fixed; z-index: 200; min-width: 210px; max-width: 320px; max-height: calc(100vh - 8px); overflow-y: auto; padding: 4px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 10px 28px #000a; font-size: 13px; user-select: none; }
.ctx-it { display: flex; align-items: center; gap: 8px; width: 100%; padding: 5px 8px; background: none; border: 0; border-radius: 4px;
  color: var(--text); text-align: left; cursor: pointer; white-space: nowrap; }
.ctx-it .ic { width: 16px; text-align: center; color: var(--muted); flex: none; }
.ctx-it .ic:not(:has(.sw)) { filter: grayscale(1) brightness(1.4); }
.ctx-it .lb { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.ctx-it kbd { font: 11px var(--mono, ui-monospace, monospace); color: var(--muted); background: none; border: 0; }
.ctx-it .ar { color: var(--muted); }
.ctx-it.hl, .ctx-it:hover { background: #22304a; }
.ctx-it[disabled] { opacity: .55; cursor: default; background: none; }
.ctx-it.danger .lb, .ctx-it.danger .ic { color: var(--down, #f0616d); }
.ctx-sep { height: 1px; margin: 4px 2px; background: var(--line); }
.ctx-head { display: flex; align-items: baseline; gap: 6px; padding: 5px 8px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctx-head .muted { overflow: hidden; text-overflow: ellipsis; }
.ctx-q { margin-left: auto; padding-left: 10px; }
.ctx-sw { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; padding: 3px 8px 5px 32px; }
.ctx-sw .muted { font-size: 12px; margin-right: 3px; }
.ctx-sw button { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--c); background: transparent; cursor: pointer;
  color: #0d1117; font-size: 11px; line-height: 13px; padding: 0; font-weight: 700; }
.ctx-sw button.on { background: var(--c); }
.ctx-sw button:hover { box-shadow: 0 0 0 2px #fff3; }
.ctx i.sw { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }
