:root {
  --bg: #0b0d12; --panel: #13161e; --panel2: #1a1e29; --border: #252a37; --text: #e8eaf0; --muted: #8a91a5;
  --accent: #7c8cff; --green: #4fd1a5; --red: #ff6b81; --radius: 14px;
  --c-cash: #4fd1a5; --c-bourse: #7c8cff; --c-crypto: #f7a440;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.loading { padding: 40px; color: var(--muted); }
.hidden { display: none !important; }

/* layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { border-right: 1px solid var(--border); padding: 22px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { font-weight: 700; font-size: 18px; padding: 0 10px 18px; display: flex; gap: 10px; align-items: center; }
.brand img { width: 26px; height: 26px; }
.nav a { display: block; padding: 9px 12px; border-radius: 10px; color: var(--muted); }
.nav a.active, .nav a:hover { background: var(--panel2); color: var(--text); }
.side .grow { flex: 1; }
.side .me { color: var(--muted); font-size: 13px; padding: 8px 12px; }
main { padding: 26px 34px 60px; max-width: 1200px; width: 100%; }
@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; bottom: 0; top: auto; height: auto; width: 100%; flex-direction: row; background: var(--panel); z-index: 10; border-right: 0; border-top: 1px solid var(--border); padding: 6px; padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .brand, .side .grow, .side .me { display: none; }
  .nav { display: flex; width: 100%; justify-content: space-around; }
  .nav a { font-size: 13px; padding: 8px; }
  main { padding: 18px 14px 90px; }
}

/* controls */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.seg button { background: none; border: 0; padding: 6px 12px; border-radius: 8px; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--panel2); color: var(--text); }
.btn { background: var(--accent); color: #0b0d12; border: 0; border-radius: 10px; padding: 8px 14px; cursor: pointer; font-weight: 600; }
.btn.ghost { background: var(--panel2); color: var(--text); border: 1px solid var(--border); font-weight: 500; }
.btn.danger { background: transparent; color: var(--red); border: 1px solid #4a2530; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.iconbtn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.iconbtn:hover { background: var(--panel2); color: var(--text); }

/* cards */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.grid2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 1000px) { .grid2 { grid-template-columns: 1fr; } }
.hero .label { color: var(--muted); font-size: 13px; }
.hero .total { font-size: 38px; font-weight: 700; letter-spacing: -0.02em; margin: 2px 0; }
.delta { font-weight: 600; font-size: 14px; }
.up { color: var(--green); } .down { color: var(--red); }
.chart-wrap { position: relative; height: 260px; margin-top: 12px; }
.donut-wrap { position: relative; height: 200px; }
.legend { margin-top: 14px; display: grid; gap: 8px; }
.legend .row { display: flex; align-items: center; gap: 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.legend .row .v { margin-left: auto; text-align: right; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

h1 { font-size: 24px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 10px; display: flex; align-items: center; gap: 10px; }
h2 .v { margin-left: auto; font-weight: 600; }
.section { margin-top: 16px; }

.list { display: grid; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-top: 1px solid var(--border); cursor: pointer; }
.item:first-child { border-top: 0; }
.item:hover { background: rgba(255,255,255,0.02); }
.item .avatar { width: 34px; height: 34px; border-radius: 10px; background: var(--panel2); display: grid; place-items: center; font-weight: 700; font-size: 13px; color: var(--muted); flex: none; }
.item .main { flex: 1; min-width: 0; }
.item .main .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .main .s { color: var(--muted); font-size: 12.5px; }
.item .right { text-align: right; }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: var(--panel2); color: var(--muted); border: 1px solid var(--border); }
.badge.err { color: var(--red); border-color: #4a2530; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-top: 1px solid var(--border); font-size: 14px; }
th { color: var(--muted); font-weight: 500; font-size: 12.5px; border-top: 0; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }

/* forms */
form.f { display: grid; gap: 12px; }
.f label { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }
.f input, .f select, .f textarea { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px; color: var(--text); width: 100%; }
.f textarea { min-height: 90px; font-family: ui-monospace, monospace; font-size: 13px; }
.f input:focus, .f select:focus, .f textarea:focus { outline: none; border-color: var(--accent); }
.f .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.f .row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.f .check { display: flex; gap: 8px; align-items: center; color: var(--text); }
.f .check input { width: auto; }
.f .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.err-msg { color: var(--red); font-size: 13px; min-height: 1em; }
.suggest { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; max-height: 220px; overflow: auto; }
.suggest div { padding: 7px 10px; cursor: pointer; font-size: 13px; }
.suggest div:hover { background: var(--border); }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: 100%; max-width: 380px; }
.auth h1 { margin-bottom: 16px; display: flex; gap: 10px; align-items: center; }
.auth h1 img { width: 30px; }

/* modal & toast */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-box { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--border); padding: 10px 16px; border-radius: 10px; z-index: 60; }
@media (max-width: 800px) { .toast { bottom: 84px; } }

/* privacy mode */
body.privacy .amt { filter: blur(7px); }
