:root {
  --bg: #0f1720; --card: #17212c; --line: #243241; --text: #e6edf3; --muted: #8b9bab;
  --accent: #3fb68b; --accent-ink: #06130e; --warn: #e0a23a; --bad: #e5534b; --info: #58a6ff;
  --stocks: #58a6ff; --bonds: #3fb68b; --gold: #e0a23a; --cash: #8b9bab; --other: #a371f7;
  --radius: 14px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f4f6f8; --card: #fff; --line: #e1e6eb; --text: #14202b; --muted: #5d6b78;
          --accent: #1f8f66; --accent-ink: #fff; color-scheme: light; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.error { color: var(--bad); min-height: 1.2em; margin: 6px 0 0; }
h3 { margin: 0 0 10px; font-size: 15px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.brand img { width: 24px; height: 24px; border-radius: 6px; }
.badge { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 99px; background: var(--line); color: var(--muted); }
.badge.live { background: var(--bad); color: #fff; }

main { padding: 12px 12px calc(env(safe-area-inset-bottom) + 80px); max-width: 860px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.row { display: flex; gap: 8px; align-items: center; } .row.end { justify-content: flex-end; }
.row input { flex: 1; }
.grow { flex: 1; }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpis div { display: flex; flex-direction: column; } .kpis strong { font-size: 18px; font-variant-numeric: tabular-nums; }

.alloc { margin-top: 14px; }
.alloc .bar { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--line); }
.alloc .bar span { display: block; height: 100%; }
.alloc .legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 6px 12px; margin-top: 10px; font-size: 13px; }
.alloc .legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; }
.dev-ok { color: var(--accent); } .dev-warn { color: var(--warn); } .dev-bad { color: var(--bad); }

.group-title { margin: 16px 4px 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.pos { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 14px; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; margin-bottom: 6px; }
.pos .t { font-weight: 600; } .pos .v { text-align: right; font-variant-numeric: tabular-nums; }
.pos .s { font-size: 12px; color: var(--muted); } .pos .r { font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.pos .meter { grid-column: 1 / -1; height: 4px; background: var(--line); border-radius: 99px; margin-top: 6px; position: relative; }
.pos .meter b { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 99px; background: var(--stocks); }
.pos .meter u { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); left: 66.6%; }
.up { color: var(--accent); } .down { color: var(--bad); }

.filters { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 10px; }
.chip { border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 99px; padding: 5px 11px; font-size: 13px; }
.chip.active { background: var(--text); color: var(--bg); }
.asset { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 14px; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; margin-bottom: 6px; }
.asset .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.state { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--line); color: var(--muted); }
.state.active { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }
.state.pending { background: color-mix(in srgb, var(--info) 20%, transparent); color: var(--info); }
.state.removing_gently, .state.disabled { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.state.removing_force { background: color-mix(in srgb, var(--bad) 22%, transparent); color: var(--bad); }

.rep { display: flex; justify-content: space-between; padding: 12px 14px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; margin-bottom: 6px; color: var(--text); text-decoration: none; width: 100%; text-align: left; font: inherit; }

.chart svg { width: 100%; height: 180px; display: block; }
.chart .axis { fill: var(--muted); font-size: 18px; }
.log { margin: 0; max-height: 240px; overflow: auto; font: 11px/1.45 ui-monospace, Menlo, monospace; white-space: pre-wrap; color: var(--muted); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

input { width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
label input { margin-top: 5px; color: var(--text); }
button { font: inherit; border-radius: 10px; padding: 10px 14px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.ghost { background: transparent; }
button.danger, button.ghost.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 50%, transparent); }
button.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
button:disabled { opacity: .5; }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { border: 0; border-radius: 0; background: transparent; color: var(--muted); padding: 13px 4px; font-size: 13px; }
.tabs button.active { color: var(--text); font-weight: 600; }

.screen { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 360px; } .login .brand { margin-bottom: 18px; font-size: 20px; }
.login button { width: 100%; }

dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--text); padding: 0; max-width: 420px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(0, 0, 0, .55); }
.dialog { padding: 16px; }

.report { position: fixed; inset: 0; z-index: 20; background: var(--bg); display: flex; flex-direction: column; }
.report-bar { display: flex; justify-content: space-between; align-items: center; padding: calc(env(safe-area-inset-top) + 8px) 12px 8px; border-bottom: 1px solid var(--line); }
.report iframe { flex: 1; border: 0; width: 100%; background: #fff; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 70px); z-index: 30;
  background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; max-width: 92%; font-size: 14px; }
