/* TradePilot AI — dark-first trading UI. Chart colours follow the validated
   dataviz palette (blue / yellow / magenta / violet series on #1a1a19). */
:root, :root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232322; --surface-3: #2c2c2a; --hover: #262624;
  --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781; --grid: #2c2c2a; --baseline: #383835;
  --border: rgba(255,255,255,.10); --border-2: rgba(255,255,255,.16);
  --accent: #3987e5; --accent-ink: #fff; --accent-soft: rgba(57,135,229,.16);
  --up: #0ca30c; --down: #e66767; --up-soft: rgba(12,163,12,.14); --down-soft: rgba(230,103,103,.14);
  --warn: #fab219; --serious: #ec835a; --crit: #d03b3b;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --candle-up: #19a974; --candle-down: #e05b5b;
  --shadow: 0 10px 40px rgba(0,0,0,.45);
}
:root[data-theme="light"] {
  color-scheme: light;
  --page: #f4f4f1; --surface: #fcfcfb; --surface-2: #f3f3f0; --surface-3: #e9e9e4; --hover: #efefea;
  --ink: #0b0b0b; --ink-2: #52514e; --muted: #77756f; --grid: #e1e0d9; --baseline: #c3c2b7;
  --border: rgba(11,11,11,.10); --border-2: rgba(11,11,11,.18);
  --accent: #2a78d6; --accent-soft: rgba(42,120,214,.12);
  --up: #006300; --down: #c22f2f; --up-soft: rgba(0,130,0,.10); --down-soft: rgba(200,50,50,.10);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --candle-up: #12936a; --candle-down: #d64545;
  --shadow: 0 10px 40px rgba(0,0,0,.14);
}
/* colour-blind friendly up/down: blue / orange */
:root[data-cb="1"] { --up: #3987e5; --down: #ec835a; --up-soft: rgba(57,135,229,.16); --down-soft: rgba(236,131,90,.16); --candle-up: #3987e5; --candle-down: #ec835a; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--page); color: var(--ink); font: 13.5px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 16px; } h3 { font-size: 14px; } h4 { font-size: 12.5px; color: var(--ink-2); }
.num, td.n, .tab-num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
.grow { flex: 1; }
.muted { color: var(--muted); } .ink2 { color: var(--ink-2); }
.up { color: var(--up); } .down { color: var(--down); }
.small { font-size: 12px; } .tiny { font-size: 11px; }
.nowrap { white-space: nowrap; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 8px; }
.sp { justify-content: space-between; }
.mt { margin-top: 12px; } .mb { margin-bottom: 12px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- layout ---- */
.app { display: grid; grid-template-columns: 210px 1fr; grid-template-rows: 54px 1fr; height: 100vh; }
.side { grid-row: 1 / 3; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 14px 16px; color: var(--ink); font-size: 15px; font-weight: 600; }
.brand:hover { text-decoration: none; }
.brand b { color: var(--accent); }
.nav { display: flex; flex-direction: column; padding: 6px 8px; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink-2); }
.nav a i { width: 20px; text-align: center; font-style: normal; opacity: .85; }
.nav a:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.side-foot { margin-top: auto; padding: 12px 14px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--border); }
.top { display: flex; align-items: center; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--border); background: var(--surface); min-width: 0; }
.view { overflow-y: auto; padding: 18px 22px 40px; outline: none; min-width: 0; }

/* ---- controls ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 13px; border-radius: 8px; border: 1px solid var(--border-2); background: var(--surface-2); color: var(--ink); cursor: pointer; white-space: nowrap; font-weight: 550; line-height: 1.2; }
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn.pri { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn.pri:hover { filter: brightness(1.1); }
.btn.buy { background: var(--up); border-color: transparent; color: #fff; }
.btn.sell { background: var(--down); border-color: transparent; color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--hover); color: var(--ink); }
.btn.sm { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: default; }
.ai-btn { background: linear-gradient(135deg, #3987e5, #9085e9); border: 0; color: #fff; }
.icon-btn { position: relative; background: transparent; border: 0; padding: 6px 8px; border-radius: 8px; cursor: pointer; color: var(--ink-2); font-size: 15px; }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn b { position: absolute; top: 0; right: 0; background: var(--crit); color: #fff; font-size: 10px; border-radius: 9px; padding: 0 5px; line-height: 16px; }
input[type=text], input[type=number], input[type=search], input[type=password], select, textarea {
  background: var(--surface-2); border: 1px solid var(--border-2); border-radius: 8px; padding: 7px 10px; outline: none; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
select { cursor: pointer; }
textarea { resize: vertical; width: 100%; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); }
label.chk { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 12.5px; color: var(--ink-2); }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 2px; gap: 2px; flex-shrink: 0; }
.seg button { border: 0; background: transparent; padding: 5px 11px; border-radius: 7px; cursor: pointer; color: var(--ink-2); font-weight: 550; white-space: nowrap; }
.seg button.on { background: var(--surface-3); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.seg.sm button { padding: 3px 8px; font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border-2); background: var(--surface-2); font-size: 12px; color: var(--ink-2); cursor: default; white-space: nowrap; }
button.chip { cursor: pointer; }
button.chip:hover { color: var(--ink); border-color: var(--muted); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }
.chip b { color: var(--ink); font-weight: 600; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 9px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 550; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }

/* ---- search ---- */
.search { position: relative; flex: 1; max-width: 520px; min-width: 120px; }
.search input { width: 100%; padding-left: 32px; background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23898781' stroke-width='2.5'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") no-repeat 11px center; }
.search-res { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border-2); border-radius: 10px; box-shadow: var(--shadow); z-index: 50; max-height: 420px; overflow-y: auto; padding: 4px; }
.sr { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; padding: 7px 10px; border-radius: 7px; cursor: pointer; align-items: center; }
.sr.on, .sr:hover { background: var(--hover); }
.sr .sym { font-weight: 650; }
.sr .nm { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clocks { display: flex; gap: 10px; font-size: 11.5px; color: var(--ink-2); white-space: nowrap; }
.clock { display: flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--border); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); display: inline-block; flex-shrink: 0; }
.dot.open { background: var(--up); box-shadow: 0 0 0 3px var(--up-soft); animation: pulse 2s infinite; }
.dot.pre, .dot.post, .dot.lunch { background: var(--warn); }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px transparent; } }

/* ---- cards / grid ---- */
.page-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-h { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; min-height: 24px; }
.card-h h2, .card-h h3 { flex: 1; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.kpi { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.kpi .k { font-size: 11.5px; color: var(--muted); }
.kpi .v { font-size: 18px; font-weight: 650; margin-top: 2px; }
.kpi .s { font-size: 11.5px; margin-top: 1px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1px; background: var(--border); border-radius: 10px; overflow: hidden; }
.stat-grid > div { background: var(--surface); padding: 8px 11px; }
.stat-grid .k { font-size: 11px; color: var(--muted); }
.stat-grid .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.empty { padding: 30px 16px; text-align: center; color: var(--muted); }
.note { font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.banner { padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); border: 1px solid var(--accent); font-size: 12.5px; margin-bottom: 14px; }
.banner.warn { background: rgba(250,178,25,.10); border-color: rgba(250,178,25,.5); }
.skel { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: sk 1.3s infinite; border-radius: 8px; min-height: 16px; }
@keyframes sk { to { background-position: -200% 0; } }
.spin { width: 16px; height: 16px; border: 2px solid var(--border-2); border-top-color: var(--accent); border-radius: 50%; animation: rot .8s linear infinite; display: inline-block; vertical-align: -3px; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ---- tables ---- */
.tbl-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.t th { text-align: left; font-weight: 550; color: var(--muted); padding: 7px 9px; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; background: var(--surface); z-index: 1; font-size: 11.5px; }
.t th.n, .t td.n { text-align: right; }
.t th[data-sort] { cursor: pointer; user-select: none; }
.t th[data-sort]:hover { color: var(--ink); }
.t th.sorted { color: var(--ink); }
.t td { padding: 7px 9px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
.t tbody tr { cursor: default; }
.t tbody tr.click { cursor: pointer; }
.t tbody tr:hover { background: var(--hover); }
.t .sym { font-weight: 650; color: var(--ink); }
.t .nm { color: var(--ink-2); max-width: 220px; overflow: hidden; text-overflow: ellipsis; display: block; font-size: 11.5px; }
.t td.wrap { white-space: normal; }
.flash-up { animation: fu 1.2s; } .flash-down { animation: fd 1.2s; }
@keyframes fu { from { background: var(--up-soft); } } @keyframes fd { from { background: var(--down-soft); } }

/* ---- signals / badges ---- */
.sig { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 650; white-space: nowrap; }
.sig.sb { background: var(--up); color: #fff; } .sig.b { background: var(--up-soft); color: var(--up); }
.sig.h { background: var(--surface-3); color: var(--ink-2); }
.sig.s { background: var(--down-soft); color: var(--down); } .sig.ss { background: var(--down); color: #fff; }
.score { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 22px; border-radius: 6px; font-weight: 700; font-size: 12px; font-variant-numeric: tabular-nums; padding: 0 5px; }
.risk { font-size: 10.5px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--border-2); color: var(--muted); }
.risk.high { color: var(--serious); border-color: rgba(236,131,90,.45); }
.tag { display: inline-block; font-size: 10.5px; padding: 1px 6px; border-radius: 5px; background: var(--surface-3); color: var(--ink-2); margin: 1px 2px 1px 0; white-space: nowrap; }
.tag.bull { background: var(--up-soft); color: var(--up); } .tag.bear { background: var(--down-soft); color: var(--down); }
.pill-mkt { font-size: 10px; padding: 0 5px; border-radius: 4px; background: var(--surface-3); color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.pill-etf { background: var(--accent-soft); color: var(--accent); }
.pill-lev { background: rgba(236,131,90,.16); color: var(--serious); }
.wbar { display: grid; grid-template-columns: 150px 1fr 48px; gap: 8px; align-items: center; font-size: 12px; padding: 2px 0; }
.wbar .bar { height: 8px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.wbar .bar i { display: block; height: 100%; background: var(--s1); border-radius: 4px; }

/* ---- ticker strip ---- */
.strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 14px; }
.tick { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; display: grid; grid-template-columns: 1fr auto; gap: 0 6px; align-items: center; min-width: 0; }
.tick .tn { font-size: 11.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tick .tp { font-weight: 650; font-variant-numeric: tabular-nums; }
.tick .tc { font-size: 11.5px; font-variant-numeric: tabular-nums; }
.tick svg { grid-row: 1 / 3; grid-column: 2; }

/* ---- AI widgets ---- */
.gauge { position: relative; width: 150px; height: 88px; flex-shrink: 0; }
.gauge .gv { position: absolute; left: 0; right: 0; bottom: 4px; text-align: center; font-size: 28px; font-weight: 750; font-variant-numeric: tabular-nums; }
.gauge .gl { position: absolute; left: 0; right: 0; bottom: -14px; text-align: center; font-size: 11px; color: var(--muted); }
.dist { display: flex; height: 26px; border-radius: 7px; overflow: hidden; gap: 2px; }
.dist > div { display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 650; color: #fff; min-width: 2px; }
.factor { display: grid; grid-template-columns: 130px 1fr 44px; align-items: center; gap: 8px; font-size: 12px; padding: 3px 0; }
.factor .bar { position: relative; height: 8px; background: var(--surface-3); border-radius: 4px; }
.factor .bar i { position: absolute; top: 0; bottom: 0; border-radius: 4px; }
.factor .bar::after { content: ''; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--baseline); }
.factor-note { grid-column: 1 / -1; color: var(--muted); font-size: 11.5px; margin: -2px 0 4px; }
.ctx { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ctx li { display: grid; grid-template-columns: 18px 1fr; gap: 6px; font-size: 12.5px; color: var(--ink-2); }
.ctx li b { font-weight: 700; text-align: center; }
.narr { font-size: 13px; line-height: 1.6; color: var(--ink-2); }
.pick { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); cursor: pointer; align-items: center; border: 1px solid transparent; }
.pick:hover { border-color: var(--border-2); }
.pick .ph { font-size: 12px; color: var(--ink-2); grid-column: 1 / -1; }
.picks-list { display: flex; flex-direction: column; gap: 8px; }

/* trade plan ladder */
.ladder { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; }
.lad { display: grid; grid-template-columns: 112px 1fr auto; gap: 8px; align-items: center; padding: 5px 9px; border-radius: 7px; background: var(--surface-2); }
.lad .lp { font-weight: 650; font-variant-numeric: tabular-nums; }
.lad.tgt { border-left: 3px solid var(--up); }
.lad.zone { border-left: 3px solid var(--accent); background: var(--accent-soft); }
.lad.stop { border-left: 3px solid var(--down); }
.lad.now { border-left: 3px solid var(--ink-2); background: transparent; border: 1px dashed var(--border-2); }

/* ---- heatmap ---- */
.heat { position: relative; width: 100%; height: 420px; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.heat .sec { position: absolute; box-shadow: inset 0 0 0 1px var(--page); }
.heat .sec > span { position: absolute; left: 4px; top: 2px; font-size: 10.5px; font-weight: 650; color: rgba(255,255,255,.85); z-index: 2; text-shadow: 0 1px 2px rgba(0,0,0,.6); pointer-events: none; white-space: nowrap; overflow: hidden; max-width: calc(100% - 8px); }
.heat .tile { position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: inset 0 0 0 1px rgba(0,0,0,.35); cursor: pointer; overflow: hidden; color: #fff; text-align: center; line-height: 1.15; }
.heat .tile:hover { box-shadow: inset 0 0 0 2px #fff; z-index: 3; }
.heat .tile b { font-size: 11px; } .heat .tile small { font-size: 10px; opacity: .9; }

/* ---- charts ---- */
.chart-box { position: relative; width: 100%; height: 520px; user-select: none; touch-action: none; }
.chart-box canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.chart-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 11.5px; color: var(--ink-2); }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }
.line-box { position: relative; width: 100%; height: 260px; }
.line-box canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ---- stock page ---- */
.quote-head { display: flex; gap: 18px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.quote-head .px { font-size: 30px; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1; }
.quote-head .chg { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.range-bar { position: relative; height: 6px; background: var(--surface-3); border-radius: 3px; margin: 8px 0 3px; }
.range-bar i { position: absolute; top: -4px; width: 3px; height: 14px; background: var(--ink); border-radius: 2px; }
.news-item { display: grid; grid-template-columns: 24px 1fr; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.news-item:last-child { border-bottom: 0; }
.news-item a { color: var(--ink); }
.news-item .meta { font-size: 11px; color: var(--muted); }

/* ---- copilot ---- */
.drawer { position: fixed; top: 54px; right: 0; bottom: 0; width: min(480px, 100vw); background: var(--surface); border-left: 1px solid var(--border-2); box-shadow: var(--shadow); z-index: 40; display: flex; flex-direction: column; }
.drawer-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.drawer-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 100%; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; padding: 9px 13px; border-radius: 14px 14px 4px 14px; max-width: 85%; white-space: pre-wrap; }
.msg.ai { align-self: stretch; }
.msg.ai .md { line-height: 1.6; }
.tool-row { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 6px; }
.tool-chip { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.tool-chip.run::before { content: ''; display: inline-block; width: 8px; height: 8px; border: 1.5px solid var(--muted); border-top-color: transparent; border-radius: 50%; animation: rot .8s linear infinite; margin-right: 5px; vertical-align: -1px; }
.tool-chip.err { color: var(--down); }
.composer { border-top: 1px solid var(--border); padding: 10px; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; max-height: 160px; min-height: 40px; }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; }
.proposal { border: 1px solid var(--accent); background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; margin-top: 8px; font-size: 12.5px; }
.md p { margin: 0 0 8px; } .md p:last-child { margin-bottom: 0; }
.md ul, .md ol { margin: 4px 0 8px; padding-left: 20px; }
.md li { margin: 2px 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 10px 0 6px; font-size: 14px; }
.md code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.md pre { background: var(--surface-2); padding: 10px; border-radius: 8px; overflow-x: auto; }
.md table { border-collapse: collapse; margin: 6px 0 10px; font-size: 12px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border-2); padding: 4px 8px; text-align: left; white-space: nowrap; }
.md th { background: var(--surface-2); }
.md a { text-decoration: underline; }
.md blockquote { margin: 6px 0; padding-left: 10px; border-left: 3px solid var(--border-2); color: var(--ink-2); }
.copilot-page { display: grid; grid-template-columns: 240px 1fr; gap: 14px; height: calc(100vh - 54px - 58px); }
.chat-list { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.chat-list a { display: block; padding: 7px 10px; border-radius: 7px; color: var(--ink-2); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-list a.on, .chat-list a:hover { background: var(--hover); color: var(--ink); text-decoration: none; }

/* ---- notifications / toasts / modal / login ---- */
.notif-panel { position: fixed; top: 52px; right: 120px; width: 360px; max-height: 70vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border-2); border-radius: 12px; box-shadow: var(--shadow); z-index: 45; padding: 6px; }
.notif { padding: 9px 11px; border-radius: 8px; font-size: 12.5px; }
.notif:hover { background: var(--hover); }
.notif b { display: block; }
.toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--surface-3); border: 1px solid var(--border-2); border-left: 4px solid var(--accent); border-radius: 10px; padding: 10px 14px; box-shadow: var(--shadow); max-width: 380px; font-size: 12.5px; animation: tin .2s; }
.toast.err { border-left-color: var(--crit); } .toast.ok { border-left-color: var(--up); }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 80; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-box { background: var(--surface); border: 1px solid var(--border-2); border-radius: 14px; box-shadow: var(--shadow); width: min(560px, 100%); max-height: 90vh; overflow-y: auto; padding: 18px 20px; }
.modal-box.wide { width: min(820px, 100%); }
.login { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--page); padding: 16px; z-index: 90; }
.login .card { width: min(380px, 100%); padding: 26px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; align-items: end; }
.order-side { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.order-side button { padding: 8px; border-radius: 8px; border: 1px solid var(--border-2); background: var(--surface-2); cursor: pointer; font-weight: 650; }
.order-side button.on.b { background: var(--up); color: #fff; border-color: transparent; }
.order-side button.on.s { background: var(--down); color: #fff; border-color: transparent; }
.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; padding: 10px; font-size: 12px; color: var(--muted); }
.disclaimer { font-size: 11px; color: var(--muted); margin-top: 24px; padding-top: 12px; border-top: 1px solid var(--border); line-height: 1.5; }

/* ---- responsive ---- */
@media (max-width: 1200px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .clocks .clock span.cd { display: none; } }
@media (max-width: 1000px) {
  .g-main, .g3 { grid-template-columns: minmax(0, 1fr); }
  .app { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; }
  .side { grid-row: auto; flex-direction: row; border-right: 0; border-bottom: 1px solid var(--border); overflow-x: auto; overflow-y: hidden; }
  .brand span { display: none; }
  .nav { flex-direction: row; padding: 4px; }
  .nav a { padding: 8px 9px; white-space: nowrap; }
  .nav a span { font-size: 12px; }
  .side-foot { display: none; }
  .clocks { display: none; }
  .copilot-page { grid-template-columns: 1fr; height: auto; }
  .copilot-page .chat-list { display: none; }
}
@media (max-width: 700px) {
  .view { padding: 14px 16px 30px; }
  .g2, .g4 { grid-template-columns: minmax(0, 1fr); }
  .top { flex-wrap: wrap; padding: 8px 16px; gap: 8px; }
  .search { order: 5; max-width: none; flex-basis: 100%; }
  .nav a span { display: none; }
  .chart-box { height: 420px; }
  .factor { grid-template-columns: 100px 1fr 38px; }
  .notif-panel { right: 8px; left: 8px; width: auto; }
  .ai-btn { padding: 6px 10px; }
}
