:root {
  --bg: #1b1c1f;
  --card: #25262a;
  --line: #34363b;
  --grid: #2f3136;
  --text: #e8e8e8;
  --muted: #9b9ea4;
  --orange: #ff8c1a;
  --orange-soft: rgba(255, 140, 26, .16);
  --in: #3fb950;
  --out: #f0605a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow-x: hidden; }
.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
h1 { margin: 0; font-size: 20px; color: var(--orange); letter-spacing: .5px; }
h2 { margin: 0 0 10px; font-size: 16px; font-weight: 600; }
main { max-width: 1180px; margin: 0 auto; padding: 12px 16px 40px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin: 12px 0; min-width: 0; }
.narrow { max-width: 420px; margin: 40px auto; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.note { font-size: 13px; margin: 6px 0 0; }
button, .button, select, input {
  font: inherit; color: var(--text); background: #2e3035; border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 11px; min-height: 36px;
}
button, .button { cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; }
button.primary { background: var(--orange); color: #1b1c1f; border-color: var(--orange); font-weight: 600; width: 100%; justify-content: center; margin-top: 10px; }
button.ghost, .button.ghost { background: transparent; }
button:focus-visible, select:focus-visible, input:focus-visible, .button:focus-visible { outline: 2px solid var(--orange); outline-offset: 1px; }
label { display: block; margin: 8px 0; color: var(--muted); font-size: 13px; }
label input { display: block; width: 100%; margin-top: 4px; }
.msg { min-height: 1.2em; font-size: 13px; color: var(--muted); }
.msg.bad { color: var(--out); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 8px 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: transparent; padding: 7px 10px; }
.seg button.on { background: var(--orange); color: #1b1c1f; font-weight: 600; }
.range { display: inline-flex; gap: 4px; align-items: center; }
.range input { padding: 6px 6px; max-width: 150px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 6px 0; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.kpi .l { color: var(--muted); font-size: 12px; }
.kpi .v { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi.hero .v { color: var(--orange); font-size: 24px; }
.kpi .s { font-size: 12px; color: var(--muted); }
.up { color: var(--in); } .down { color: var(--out); }

.chart { position: relative; width: 100%; min-height: 220px; }
.chart > svg { display: block; width: 100%; height: 240px; touch-action: pan-y; }
.chart text { fill: var(--muted); font-size: 11px; }
.legend { font-size: 13px; color: var(--muted); display: flex; gap: 6px 14px; flex-wrap: wrap; align-items: center; margin-bottom: 4px; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: -8px; }
.key.in { background: var(--in); } .key.out { background: var(--out); }
.tip { position: fixed; z-index: 30; pointer-events: none; background: #111214; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; font-size: 13px; max-width: 260px; box-shadow: 0 4px 16px rgba(0,0,0,.4); }
.tip b { color: var(--orange); font-weight: 600; }

.two { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 860px) { .two { grid-template-columns: 1fr 1fr; } }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
td.n, th.n { text-align: right; }
.tx-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.tx-tools input { flex: 1 1 200px; min-width: 0; }
.legs { white-space: normal; min-width: 180px; }
.leg-fee { color: var(--muted); }
.tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 10px; border: 1px solid var(--line); color: var(--muted); }
.tag.trade { border-color: var(--orange); color: var(--orange); }

.drop { border: 1px dashed var(--muted); border-radius: 10px; padding: 18px; text-align: center; cursor: pointer; color: var(--text); }
.drop.over { border-color: var(--orange); background: var(--orange-soft); }
.drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
#preview { margin-top: 10px; font-size: 13.5px; }
#health ul { margin: 4px 0 8px; padding-left: 18px; font-size: 13.5px; }
#health h3 { font-size: 13px; margin: 10px 0 2px; color: var(--muted); font-weight: 500; }
.warn::before { content: "! "; color: var(--orange); font-weight: 700; }
.ok::before { content: "✓ "; color: var(--in); }
.files td:first-child { white-space: normal; overflow-wrap: anywhere; min-width: 140px; }

/* details (#764): what can be pressed, and the panel it opens */
tr.go, .kpi[data-go], .chip { cursor: pointer; }
tr.go:hover td, tr.go:focus-visible td { background: #2c2e33; }
tr.go:focus-visible { outline: 2px solid var(--orange); outline-offset: -2px; }
.kpi[data-go]:hover, .kpi[data-go]:focus-visible { border-color: var(--orange); outline: none; }
a[data-go] { color: var(--orange); text-decoration: none; border-bottom: 1px dotted var(--orange); }
.look { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0 4px; }
.chip { flex-direction: column; align-items: flex-start; gap: 1px; padding: 6px 11px; border-radius: 10px; background: var(--card); font-size: 13px; line-height: 1.25; text-align: left; }
.chip:hover { border-color: var(--orange); }
.chip b { font-weight: 600; font-variant-numeric: tabular-nums; }
.rec { color: var(--muted); font-size: 12.5px; margin: 2px 0 6px; padding-left: 8px; border-left: 2px solid var(--orange); }
.panel-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 5; }
.panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); z-index: 6; background: var(--bg); border-left: 1px solid var(--line);
  overflow-y: auto; overscroll-behavior: contain; padding: 0 16px 40px; box-shadow: -8px 0 24px rgba(0, 0, 0, .4); }
.panel-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 8px; background: var(--bg); padding: 10px 0; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.panel-head h2 { flex: 1; margin: 0; color: var(--orange); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-head button { min-width: 40px; justify-content: center; }
.panel h3 { font-size: 13px; color: var(--muted); font-weight: 500; margin: 16px 0 4px; }
.insights { margin: 0 0 10px; padding-left: 18px; }
.insights li { margin: 4px 0; }
.kgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 6px; margin: 8px 0; }
.kgrid div { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; display: flex; flex-direction: column; min-width: 0; }
.kgrid div[data-go] { cursor: pointer; }
.kgrid div[data-go]:hover { border-color: var(--orange); }
.seg.chips { flex-wrap: wrap; margin: 4px 0 8px; }
.kgrid b { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.chart.mini { min-height: 130px; }
.chart.mini > svg { height: 130px; }
body.noscroll { overflow: hidden; }

/* the assistant (#768) */
.fab { position: fixed; right: 16px; bottom: 16px; z-index: 3; background: var(--orange); color: #1b1c1f; border-color: var(--orange);
  font-weight: 650; border-radius: 24px; padding: 10px 20px; min-height: 46px; box-shadow: 0 4px 16px rgba(0, 0, 0, .45); }
.chat { position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100%); z-index: 4; background: var(--bg); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; box-shadow: -8px 0 24px rgba(0, 0, 0, .4); }
.chat-head { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.chat-head h2 { flex: 1; margin: 0; color: var(--orange); min-width: 0; }
.chat-head > button { min-width: 38px; justify-content: center; padding: 6px 8px; }
.chat-head .seg button { padding: 6px 9px; font-size: 13px; }
.sees { margin: 0; padding: 5px 12px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.chat-log, .chat-list { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 10px 12px; min-height: 0; }
.chat-list h3 { font-size: 13px; color: var(--muted); font-weight: 500; margin: 12px 0 6px; }
.chat-item { width: 100%; justify-content: space-between; gap: 10px; margin: 0 0 6px; text-align: left; }
.chat-item span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.change { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.change.undone b { color: var(--muted); text-decoration: line-through; }
.msg-u { display: flex; justify-content: flex-end; margin: 10px 0; }
.msg-u .bubble { background: #2e3035; border: 1px solid var(--line); border-radius: 12px 12px 2px 12px; padding: 8px 11px; max-width: 85%; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-a { margin: 10px 0 16px; overflow-wrap: anywhere; font-size: 14.5px; }
.msg-a p { margin: 0 0 8px; }
.msg-a ul, .msg-a ol { margin: 0 0 8px; padding-left: 20px; }
.msg-a li { margin: 3px 0; }
.msg-a h4 { margin: 10px 0 4px; font-size: 14px; color: var(--orange); }
.msg-a b { color: #fff; }
.msg-a code { background: #2e3035; border-radius: 4px; padding: 0 4px; font-size: 13px; }
.msg-a pre { background: #111214; border: 1px solid var(--line); border-radius: 8px; padding: 8px; overflow-x: auto; font-size: 12.5px; }
.msg-a table { margin: 4px 0 10px; }
.msg-a td { white-space: normal; }
.tools { color: var(--muted); font-size: 12px; margin: 2px 0 0; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--orange); margin-right: 6px; animation: pulse 1s infinite alternate; }
@keyframes pulse { from { opacity: .3; } to { opacity: 1; } }
.prop { border: 1px solid var(--orange); border-radius: 10px; padding: 10px 12px; margin: 8px 0; background: var(--card); }
.prop.declined, .prop.undone { border-color: var(--line); opacity: .75; }
.prop.applied { border-color: var(--in); }
.prop ul { margin: 6px 0; padding-left: 18px; }
.prop p { margin: 4px 0; }
.prop-btns { display: flex; gap: 8px; margin-top: 8px; }
.prop-btns .apply { background: var(--orange); color: #1b1c1f; border-color: var(--orange); font-weight: 600; }
.small-btn { min-height: 28px; padding: 2px 8px; font-size: 12.5px; margin-left: 6px; }
.hello p { margin: 4px 0 10px; }
.hello .try { display: flex; width: 100%; text-align: left; margin: 0 0 6px; font-size: 13.5px; }
.chat-form { display: flex; gap: 8px; align-items: flex-end; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.chat-form textarea { flex: 1; min-width: 0; resize: none; font: inherit; color: var(--text); background: #2e3035; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; max-height: 40vh; }
.chat-form textarea:focus-visible { outline: 2px solid var(--orange); outline-offset: 1px; }
.chat-form .send { background: var(--orange); color: #1b1c1f; border-color: var(--orange); font-weight: 600; }
.chat-form .add-file { padding: 6px 9px; font-size: 13px; }
.chat-files { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px 0; }
.fchip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; background: #2e3035; border: 1px solid var(--line); border-radius: 8px; padding: 3px 4px 3px 9px; font-size: 12.5px; }
.fchip .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; color: var(--text); }
.fchip .fstate { color: var(--muted); white-space: nowrap; }
.fchip button { min-height: 26px; padding: 1px 7px; font-size: 12px; }
.msg-u .fchips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-top: 6px; }
.msg-u .fchip { padding-right: 9px; }
.chat.dropping .chat-log { outline: 2px dashed var(--orange); outline-offset: -6px; }
@media (max-width: 699px) { .chat { border-left: 0; } .chat-head h2 { font-size: 15px; } }

/* zoomable charts (#773): TradingView Lightweight Charts, tools top right, Bigger = the whole screen */
.chart.tv { display: flex; flex-direction: column; min-height: 0; }
.tv-pane { position: relative; height: 240px; width: 100%; }
.chart-tools { display: flex; justify-content: flex-end; gap: 6px; margin: -4px 0 6px; }
.chart-tools button { padding: 3px 10px; font-size: 12px; min-height: 28px; }
.chart-tools button.on { background: var(--orange); color: #1b1c1f; border-color: var(--orange); font-weight: 600; }
.chart.big { position: fixed; inset: 0; z-index: 20; background: var(--card); padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); margin: 0; }
.chart.big .tv-pane { flex: 1; height: auto; min-height: 0; }
body.has-big { overflow: hidden; }
