:root {
  color-scheme: light;
  --bg: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f2f1ee;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #9a6700;        /* banana, text-safe */
  --accent-fill: #f5c518;   /* banana, fills */
  --accent-ink: #1f1a00;
  --good: #0ca30c;
  --good-text: #006300;
  --bad: #d03b3b;
  --bad-text: #b02a2a;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0d0d; --surface: #1a1a19; --surface-2: #232322;
    --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
    --accent: #f5c518; --accent-fill: #f5c518; --accent-ink: #1f1a00;
    --good-text: #0ca30c; --bad-text: #e66767;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0d; --surface: #1a1a19; --surface-2: #232322;
  --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
  --accent: #f5c518; --accent-fill: #f5c518; --accent-ink: #1f1a00;
  --good-text: #0ca30c; --bad-text: #e66767;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
.num, td.n, th.n { font-variant-numeric: tabular-nums; text-align: right; }

/* ---- top bar ---- */
header.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.brand .dot { width: 14px; height: 14px; border-radius: 50% 50% 50% 0; background: var(--accent-fill); transform: rotate(-45deg); }
nav.main { display: flex; gap: 4px; }
nav.main a { padding: 6px 9px; border-radius: 8px; color: var(--ink-2); font-weight: 500; white-space: nowrap; }
nav.main a:hover { background: var(--surface-2); color: var(--ink); }
nav.main a.on { background: var(--surface-2); color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent-fill); }
.top .spacer { flex: 1; }
.asof { color: var(--muted); font-size: 12px; white-space: nowrap; }

.search { position: relative; }
.search input {
  width: 240px; padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-2); outline: none;
}
.search input:focus { border-color: var(--accent); }
.search .dd {
  position: absolute; top: 40px; right: 0; width: 320px; max-height: 360px; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
  display: none;
}
.search .dd.open { display: block; }
.search .dd div { padding: 8px 12px; cursor: pointer; display: flex; gap: 10px; align-items: baseline; }
.search .dd div.on, .search .dd div:hover { background: var(--surface-2); }
.search .dd b { min-width: 96px; }
.search .dd span { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { max-width: 1320px; margin: 0 auto; padding: 24px; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 12px; }
.sub { color: var(--ink-2); margin: 0 0 20px; }
.muted { color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* ---- tabs & chips ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tabs button {
  border: 0; background: none; padding: 10px 14px; cursor: pointer; color: var(--ink-2); font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent-fill); }
.tabs button .c { color: var(--muted); font-weight: 400; margin-left: 6px; }
.chip {
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: 5px 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2);
}
.chip.on { background: var(--surface-2); color: var(--ink); border-color: var(--axis); }
.chip .c { color: var(--muted); }
.btn {
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 7px 14px; cursor: pointer; font-weight: 500;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent-fill); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(0.95); }
.btn:disabled { opacity: 0.5; cursor: default; }

/* ---- state badges (always text + dot, never colour alone) ---- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink); white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.badge.breakout { background: var(--accent-fill); color: var(--accent-ink); }
.badge.breakout::before { background: var(--accent-ink); }
.badge.climbing::before { background: var(--good); }
.badge.forming::before { background: var(--s1); }
.badge.played::before { background: var(--muted); }
.badge.played { color: var(--ink-2); }
.badge.strong::before, .badge.heating::before { background: var(--good); }
.badge.weak::before, .badge.cooling::before { background: var(--bad); }
.badge.neutral::before, .badge.steady::before { background: var(--muted); }

.up { color: var(--good-text); }
.down { color: var(--bad-text); }

/* ---- tables ---- */
.tablewrap { overflow: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--grid); text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; background: var(--surface); color: var(--muted); font-weight: 500; font-size: 12px; cursor: pointer; user-select: none; z-index: 1; }
th:hover { color: var(--ink); }
th.sorted { color: var(--ink); }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td .nm { display: block; color: var(--muted); font-size: 12px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.rsbar { display: inline-flex; align-items: center; gap: 8px; }
.rsbar i { display: inline-block; width: 44px; height: 6px; border-radius: 3px; background: var(--grid); position: relative; overflow: hidden; }
.rsbar i::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--w); background: var(--s1); border-radius: 3px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* ---- stat tiles ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.tile .k { color: var(--muted); font-size: 12px; }
.tile .v { font-size: 24px; font-weight: 600; margin-top: 2px; letter-spacing: -0.01em; }
.tile .d { font-size: 12px; margin-top: 2px; color: var(--ink-2); }

/* ---- charts ---- */
.chartbox { position: relative; height: 260px; }
.chartbox.tall { height: 340px; }
#kline { height: 560px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }

/* ---- dials ---- */
.dials { display: none; margin-bottom: 14px; }
.dials.open { display: block; }
.dials .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px 24px; margin: 8px 0 14px; }
.dial label { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-2); margin-bottom: 4px; }
.dial label b { color: var(--ink); font-variant-numeric: tabular-nums; }
.dial input[type=range] { width: 100%; accent-color: var(--accent); }
.custom-tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--accent-fill); color: var(--accent-ink); }

/* ---- stock page ---- */
.stockhead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.stockhead .px { font-size: 28px; font-weight: 600; }
.setups { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.setup { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--surface); }
.setup .t { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-weight: 600; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; font-size: 13px; }
.kv span:nth-child(odd) { color: var(--muted); }
.kv span:nth-child(even) { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- forms ---- */
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px 16px; align-items: end; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); }
.form input, .form select { padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); outline: none; }
.form input:focus, .form select:focus { border-color: var(--accent); }
.form label.cb { flex-direction: row; align-items: center; gap: 8px; padding-bottom: 8px; }
.note { font-size: 12px; color: var(--muted); margin-top: 12px; }

.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 40px; justify-content: center; }
.spin { width: 16px; height: 16px; border: 2px solid var(--grid); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.disclaimer { margin-top: 32px; color: var(--muted); font-size: 12px; text-align: center; }

@media (max-width: 900px) {
  header.top { gap: 12px; padding: 0 16px; overflow-x: auto; }
  .asof { display: none; }
  .search input { width: 150px; }
  main { padding: 16px; }
  .grid2 { grid-template-columns: 1fr; }
  #kline { height: 440px; }
}

/* ---- pattern picker (stock page) ---- */
.patterns { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.patterns .chip { font-size: 12px; padding: 4px 10px; }
.patinfo { font-size: 12px; color: var(--ink-2); margin: -2px 0 10px; min-height: 18px; }

/* ---- chart cards (screens) ---- */
.viewtoggle { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.viewtoggle button { border: 0; background: var(--surface); padding: 6px 12px; cursor: pointer; color: var(--ink-2); }
.viewtoggle button.on { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.ccard { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px; cursor: pointer; }
.ccard:hover { border-color: var(--axis); }
.ccard .h { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 2px; }
.ccard .m { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.ccard svg { display: block; width: 100%; height: 120px; }

/* ---- portfolio ---- */
.alerts { display: flex; flex-direction: column; gap: 6px; }
.alert { display: flex; gap: 10px; align-items: baseline; padding: 8px 12px; border-radius: 8px; background: var(--surface-2); }
.alert b { min-width: 110px; flex-shrink: 0; }
.lvl { font-size: 11px; font-weight: 700; padding: 1px 8px; min-width: 52px; text-align: center; border-radius: 999px; white-space: nowrap; color: #fff; }
.lvl.critical { background: #d03b3b; }
.lvl.serious { background: #c4572c; }
.lvl.warning { background: #fab219; color: #1f1a00; }
.lvl.good { background: #0c8a0c; }
.lvl.info { background: var(--muted); }
.badge.healthy::before { background: var(--good); }
.badge.extended::before { background: #fab219; }
.badge.trend::before { background: #ec835a; }
.badge.stop::before { background: var(--bad); }
.secbars { display: flex; flex-direction: column; gap: 8px; }
.secbar { display: grid; grid-template-columns: minmax(120px, 34%) 1fr 52px; gap: 10px; align-items: center; font-size: 13px; }
.secbar .track { height: 10px; background: var(--grid); border-radius: 5px; overflow: hidden; }
.secbar .fill { height: 100%; background: var(--s1); border-radius: 5px; }
.secbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.x { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 16px; padding: 0 4px; }
.x:hover { color: var(--bad-text); }
.drop { display: block; border: 1.5px dashed var(--axis); border-radius: 12px; padding: 18px; text-align: center; color: var(--ink-2); cursor: pointer; }
.drop.over { border-color: var(--accent); background: var(--surface-2); }
.privacy { font-size: 12px; color: var(--muted); }

/* ---- news / calendar ---- */
.news { display: flex; flex-direction: column; }
.nrow { display: grid; grid-template-columns: 92px 130px 150px 1fr auto; gap: 12px; align-items: baseline; padding: 10px 14px; border-bottom: 1px solid var(--grid); }
.nrow:last-child { border-bottom: 0; }
.nrow .t { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.nrow .s a { font-weight: 600; }
.nrow .s span { display: block; color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nrow .sum { color: var(--ink); }
.nrow .pdf { font-size: 12px; color: var(--accent); white-space: nowrap; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.tag.results { background: var(--accent-fill); color: var(--accent-ink); }
.calday { margin-bottom: 14px; }
.calday h3 { font-size: 13px; margin: 0 0 6px; color: var(--ink-2); }
.calday .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.calday .chips a { font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); }
.calday .chips a:hover { border-color: var(--axis); }
.calday .chips a b { font-weight: 600; }
.calday .chips a span { color: var(--muted); margin-left: 4px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 6px 12px; cursor: pointer; color: var(--ink-2); }
.seg button.on { background: var(--surface-2); color: var(--ink); font-weight: 600; }

/* ---- watchlist button, notes ---- */
.wlbtn { position: relative; }
.wlmenu { position: absolute; right: 0; top: 40px; z-index: 30; min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; display: none; }
.wlmenu.open { display: block; }
.wlmenu label { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.wlmenu label:hover { background: var(--surface-2); }
.wlmenu input[type=text] { width: 100%; margin-top: 4px; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); }
.notes textarea { width: 100%; min-height: 70px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); font: inherit; color: inherit; resize: vertical; }
.note { border-top: 1px solid var(--grid); padding: 8px 0; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; }
.note .when { color: var(--muted); font-size: 11px; }
.note .txt { white-space: pre-wrap; grid-column: 1; }
.banner { padding: 10px 14px; border-radius: 10px; background: var(--surface-2); margin-bottom: 16px; display: flex; gap: 10px; align-items: center; }
.clip { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
@media (max-width: 900px) {
  .nrow { grid-template-columns: 1fr; gap: 2px; }
}

/* ---- home ---- */
.regime { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); margin-bottom: 16px; }
.regime .lvl { min-width: 72px; }
.lvl.healthy { background: #0c8a0c; }
.lvl.mixed { background: #fab219; color: #1f1a00; }
.lvl.soft { background: #c4572c; }
.lvl.weak { background: #d03b3b; }
.idxstrip { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.idxstrip a { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.idxstrip a:hover { border-color: var(--axis); }
.idxstrip .k { color: var(--muted); font-size: 12px; }
.idxstrip .v { font-size: 18px; font-weight: 600; margin: 2px 0; font-variant-numeric: tabular-nums; }
.idxstrip .d { font-size: 12px; }
.home { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; }
.home .col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.mini { width: 100%; border-collapse: collapse; }
.mini td, .mini th { padding: 7px 8px; border-bottom: 1px solid var(--grid); font-size: 13px; white-space: nowrap; }
.mini th { color: var(--muted); font-weight: 500; font-size: 11px; text-align: left; position: static; cursor: default; }
.mini tr:last-child td { border-bottom: 0; }
.mini tr[data-sym] { cursor: pointer; }
.mini tr[data-sym]:hover td { background: var(--surface-2); }
.cardhead { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.cardhead h2 { margin: 0; }
.cardhead a { font-size: 12px; color: var(--accent); }
.feed .item { padding: 8px 0; border-bottom: 1px solid var(--grid); font-size: 13px; }
.feed .item:last-child { border-bottom: 0; }
.feed .meta { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 11px; margin-bottom: 2px; }
.feed .meta a { color: var(--ink); font-weight: 600; font-size: 12px; }
.empty-sm { color: var(--muted); font-size: 13px; padding: 6px 0; }
@media (max-width: 1000px) { .home { grid-template-columns: 1fr; } }

/* ---- results ---- */
.qtable td.n, .qtable th.n { text-align: right; }
td .g { font-size: 11px; display: block; }
.qcharts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 12px; }
.qcharts .chartbox { height: 170px; }
@media (max-width: 900px) { .qcharts { grid-template-columns: 1fr; } }

/* ---- hover preview ---- */
.pv { position: fixed; z-index: 100; width: 360px; background: var(--surface); border: 1px solid var(--axis); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.18); padding: 12px; pointer-events: none; display: none; }
.pv.on { display: block; }
.pv .h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pv .h b { font-size: 15px; }
.pv .nm { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 6px; }
.pv svg { display: block; width: 100%; height: 160px; }
.pv .f { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--ink-2); margin-top: 6px; }
.pv .f span b { color: var(--ink); font-weight: 600; }

@media (max-width: 1500px) { .asof { display: none; } .search input { width: 180px; } header.top { gap: 14px; } }

/* ---- scans ---- */
.scanlayout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 16px; align-items: start; }
.scanlist { position: sticky; top: 72px; display: flex; flex-direction: column; gap: 2px; }
.scanlist h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 12px 8px 4px; }
.scanlist button { display: flex; justify-content: space-between; border: 0; background: none; padding: 7px 10px; border-radius: 8px; cursor: pointer; color: var(--ink-2); text-align: left; }
.scanlist button:hover { background: var(--surface-2); }
.scanlist button.on { background: var(--surface-2); color: var(--ink); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent-fill); }
.scanlist button .c { color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 900px) { .scanlayout { grid-template-columns: 1fr; } .scanlist { position: static; flex-direction: row; flex-wrap: wrap; } .scanlist h3 { display: none; } }
.chips-sm { display: flex; flex-wrap: wrap; gap: 6px; }
.chips-sm span { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }

/* ---- journal ---- */
.ctxbox { font-size: 12px; color: var(--ink-2); background: var(--surface-2); border-radius: 8px; padding: 8px 12px; margin-top: 10px; min-height: 34px; }
.ctxbox b { color: var(--ink); }
.bd { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.bd .card { overflow-x: auto; }

/* ---- warning flags ---- */
.flg { display: inline-block; font-size: 10px; font-weight: 700; line-height: 1; padding: 3px 5px; border-radius: 4px; margin-left: 4px; vertical-align: 2px; cursor: help; letter-spacing: .02em; }
.flg.asm_lt, .flg.asm_st { background: #fde2e2; color: #a12020; }
.flg.band_down { background: #fde9df; color: #9a3d10; }
.flg.band_up { background: #e2f4e2; color: #1d6b1d; }
.flg.bulk, .flg.block { background: #e1ecfb; color: #1c4f94; }
.flg.insider { background: #ece9fb; color: #4a3aa7; }
.flg.results { background: #fdf1c7; color: #6b4e00; }
:root[data-theme="dark"] .flg { filter: brightness(.85) saturate(1.2); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .flg { filter: brightness(.85) saturate(1.2); } }

/* ---- watchlist star on stock rows ---- */
.star { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 14px; line-height: 1; padding: 0 2px 0 6px; vertical-align: 1px; }
.star:hover { color: var(--accent); }
.star.on { color: var(--accent); }

/* ---- chart toolbar, indicator menu, technical checklist ---- */
#ctool .seg button { padding: 4px 10px; font-size: 12px; }
.indmenu, #drawmenu { left: 0; right: auto; width: 360px; max-height: 460px; overflow: auto; }
.indh { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px 8px 4px; }
.indh a { color: var(--accent); text-transform: none; letter-spacing: 0; }
.indrow { display: grid; grid-template-columns: 96px 1fr auto; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.indrow:hover { background: var(--surface-2); }
.indrow span { color: var(--muted); font-size: 12px; }
.indrow.on { cursor: default; }
.indrow input { width: 100%; padding: 3px 6px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); font-size: 12px; }
.ttgrid { display: grid; grid-template-columns: 18px 1fr; gap: 4px 6px; font-size: 13px; }
.ttgrid .up, .ttgrid .down { font-weight: 700; }

/* ---- AI copilot drawer ---- */
.cpbtn { position: fixed; right: 20px; bottom: 20px; z-index: 40; display: flex; align-items: center; gap: 6px; padding: 10px 16px; border-radius: 999px;
  border: 0; background: var(--accent-fill); color: var(--accent-ink); font-weight: 600; cursor: pointer; box-shadow: 0 2px 10px rgba(0, 0, 0, .18); }
.cpbtn.hide { display: none; }
.cp { position: fixed; top: 0; right: 0; bottom: 0; z-index: 45; width: min(460px, 100vw); display: none; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: -4px 0 24px rgba(0, 0, 0, .12); }
.cp.open { display: flex; }
.cp header { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.cp header h3 { margin: 0; font-size: 15px; flex: 1; }
.cp header .ctx { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.cp .ib { border: 0; background: none; cursor: pointer; padding: 4px 8px; border-radius: 6px; color: var(--ink-2); font-size: 15px; }
.cp .ib:hover { background: var(--surface-2); }
.cp .log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.cp .msg { max-width: 100%; line-height: 1.5; overflow-wrap: anywhere; }
.cp .msg.user { align-self: flex-end; background: var(--surface-2); padding: 8px 12px; border-radius: 12px 12px 2px 12px; max-width: 85%; white-space: pre-wrap; }
.cp .msg.bot p { margin: 0 0 8px; }
.cp .msg.bot h4 { margin: 10px 0 6px; font-size: 14px; }
.cp .msg.bot ul, .cp .msg.bot ol { margin: 0 0 8px; padding-left: 20px; }
.cp .msg.bot a { color: var(--accent); font-weight: 600; }
.cp .msg.bot code { background: var(--surface-2); padding: 1px 4px; border-radius: 4px; font-size: 12px; }
.cp .msg.bot .tablewrap { margin: 4px 0 10px; overflow-x: auto; }
.cp .msg.bot table { font-size: 12px; border-collapse: collapse; }
.cp .msg.bot th, .cp .msg.bot td { padding: 4px 8px; border-bottom: 1px solid var(--grid); text-align: left; white-space: nowrap; }
.cp .msg.err { color: var(--bad-text); background: var(--surface-2); padding: 8px 12px; border-radius: 8px; }
.cp .steps { display: flex; flex-wrap: wrap; gap: 4px; font-size: 11px; color: var(--muted); }
.cp .steps span { background: var(--surface-2); border-radius: 999px; padding: 2px 8px; }
.cp .meta { font-size: 11px; color: var(--muted); }
.cp .sugg { display: flex; flex-direction: column; gap: 6px; }
.cp .sugg button { text-align: left; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 8px 10px; cursor: pointer; color: var(--ink-2); }
.cp .sugg button:hover { background: var(--surface-2); color: var(--ink); }
.cp form.ask { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border); }
.cp form.ask textarea { flex: 1; resize: none; min-height: 40px; max-height: 140px; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); font: inherit; color: inherit; }
.cp .set { padding: 14px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 12px; }
.cp .set label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); }
.cp .set input, .cp .set select, .cp .set textarea { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); font: inherit; color: var(--ink); }
.cp .set textarea { min-height: 110px; resize: vertical; }
.cp .set .hint { font-size: 11px; color: var(--muted); }
@media (max-width: 600px) { .cpbtn { right: 12px; bottom: 12px; } }
