:root {
  --bg: #f6f7f9; --card: #fff; --text: #1d2330; --muted: #667085; --line: #e4e7ec;
  --accent: #2f5bd3; --good: #1a7f4b; --bad: #c0392b; --good-bg: #e6f4ec; --bad-bg: #fbeaea;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --card: #1b1f27; --text: #e6e8ec; --muted: #98a2b3; --line: #2c323d;
    --accent: #7c9cf0; --good: #4cc38a; --bad: #f07167; --good-bg: #17352a; --bad-bg: #3a1f1f;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
header { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--card); }
header h1 { font-size: 18px; margin: 0; }
main { max-width: 1200px; margin: 0 auto; padding: 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.card.danger { border-color: var(--bad-bg); }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.space { justify-content: space-between; }
label { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); }
input, select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
input[type=number] { width: 70px; }
button, .button { font: inherit; cursor: pointer; border: 0; border-radius: 6px; padding: 7px 14px; background: var(--accent); color: #fff; text-decoration: none; display: inline-block; }
button.secondary, .button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--line); }
button:disabled { opacity: .5; cursor: wait; }
.muted { color: var(--muted); font-size: 13px; }
.warn { color: var(--bad); }
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
tr.total td { font-weight: 600; border-top: 2px solid var(--line); }
tr.clickable { cursor: pointer; }
tr.selected td { background: var(--bg); }
.good { color: var(--good); }
.bad { color: var(--bad); }
td.good-bg { background: var(--good-bg); }
td.bad-bg { background: var(--bad-bg); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.tile .label { color: var(--muted); font-size: 12px; }
.tile .value { font-size: 20px; font-weight: 600; }
.chart svg { width: 100%; height: 220px; display: block; margin: 12px 0; }
.chart text { fill: var(--muted); font-size: 11px; }
.consent { max-width: 560px; margin: 40px auto; background: var(--card); padding: 24px; border-radius: 10px; border: 1px solid var(--line); }
#account { display: flex; gap: 10px; align-items: center; }
@media (max-width: 600px) { main { padding: 10px; } .card { padding: 12px; } }
button.icon { padding: 2px 8px; background: transparent; color: var(--muted); border: 1px solid var(--line); font-size: 13px; }
button.icon:hover { color: var(--bad); border-color: var(--bad); }
.actions { display: inline-flex; gap: 4px; }
h3 { font-size: 14px; margin: 16px 0 8px; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.segmented button { border-radius: 0; background: transparent; color: var(--muted); padding: 5px 12px; }
.segmented button.active { background: var(--accent); color: #fff; }
.treemap svg { width: 100%; height: auto; display: block; margin-top: 12px; }
.treemap rect { stroke: var(--card); stroke-width: 2; }
.treemap rect:hover { opacity: .85; }
.treemap text { fill: #fff; pointer-events: none; font-weight: 600; }
.treemap .loss { fill: var(--treemap-loss); }
.treemap .gain { fill: var(--treemap-gain); }
.tooltip { position: fixed; z-index: 10; pointer-events: none; background: #222a; backdrop-filter: blur(4px); color: #fff; padding: 6px 10px; border-radius: 6px; font-size: 13px; white-space: nowrap; }
:root { --treemap-loss: #b3261e; --treemap-gain: #4f8a10; }
.info { display: inline-block; margin-left: 4px; color: var(--muted); cursor: help; font-size: 12px; font-weight: 400; }
.info:hover, .info:focus { color: var(--accent); outline: none; }
.tooltip.wrap { white-space: normal; max-width: 320px; line-height: 1.35; }
.disclaimer { margin: 2px 0 0; font-size: 11px; color: var(--muted); }
.treemap rect { cursor: pointer; }
#symbol-table tbody tr { cursor: pointer; }
#symbol-detail { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.price-chart svg { width: 100%; height: auto; display: block; }
.price-chart text { fill: var(--muted); font-size: 11px; }
.price-chart .band { fill: var(--accent); fill-opacity: .12; }
.price-chart .line { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.price-chart .grid { stroke: var(--line); }
.price-chart .hold-win { fill: var(--good); fill-opacity: .10; }
.price-chart .hold-loss { fill: var(--bad); fill-opacity: .10; }
.price-chart .buy { fill: var(--good); stroke: var(--card); }
.price-chart .sell { fill: var(--bad); stroke: var(--card); }
.price-chart .marker { cursor: help; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend .buy { color: var(--good); } .legend .sell { color: var(--bad); }
#returns-table tbody tr:not(.month-trades) { cursor: pointer; }
tr.month-trades > td { text-align: left; background: var(--bg); padding: 8px 12px 12px; white-space: normal; }
tr.month-trades table { background: var(--card); }
details { margin-top: 10px; }
details > summary { cursor: pointer; color: var(--accent); font-size: 14px; }
details[open] > summary { margin-bottom: 8px; }
ul.warn { padding-left: 20px; margin: 10px 0; }
ul.warn li { margin-bottom: 4px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 12px 0; padding: 8px 12px 12px; }
legend { color: var(--muted); font-size: 13px; padding: 0 4px; }
.account-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 6px 16px; }
.account-grid label { color: var(--text); font-size: 13px; }
.account-grid input[type=number] { width: 80px; flex: none; }
details.accounts { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 14px; }
details.accounts .row { margin: 8px 0; }
nav.pages { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
nav.pages a { padding: 8px 14px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
nav.pages a:hover { color: var(--text); }
nav.pages a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; background: var(--good-bg); color: var(--good); font-size: 12px; font-weight: 600; }
