:root {
  color-scheme: dark;
  --bg: #090d17;
  --surface: #111827;
  --card: #151e2f;
  --card-strong: #1a263a;
  --text: #f3f6fb;
  --muted: #94a3b8;
  --accent: #4f8cff;
  --accent-strong: #3978ee;
  --line: #263248;
  --danger: #ff6b76;
  --success: #42d392;
  --shadow: 0 14px 34px #00000038;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 85% -10%, #21427866 0, transparent 32%),
    radial-gradient(circle at -10% 35%, #152d5260 0, transparent 34%),
    var(--bg);
  color: var(--text);
  font: 15px/1.42 system-ui, -apple-system, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; }
button { cursor: pointer; }

.app { max-width: 780px; margin: auto; padding: 18px 12px 104px; }
header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 17px; }
header small { color: #6ea3ff; font-size: 11px; font-weight: 800; letter-spacing: .18em; }
h1 { margin: 2px 0 0; font-size: 24px; letter-spacing: -.025em; }
.avatar {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(145deg, #5a95ff, #326de0); color: white; font-weight: 800;
  box-shadow: 0 8px 24px #2865d855;
}

nav {
  display: flex; gap: 7px; overflow-x: auto; margin: 0 -12px 14px; padding: 0 12px 5px;
  scrollbar-width: none; scroll-snap-type: x proximity;
}
nav::-webkit-scrollbar { display: none; }
nav button {
  min-width: 88px; flex: 0 0 88px; scroll-snap-align: start; border: 1px solid var(--line);
  border-radius: 15px; padding: 10px 4px; background: #111827cc; color: var(--muted); font-weight: 700;
  transition: .18s ease;
}
nav button img { display: block; width: 48px; height: 48px; margin: 0 auto; object-fit: contain; }
nav button:active { transform: scale(.97); }
nav span { display: block; margin-top: 4px; font-size: 11px; }
nav .active { border-color: #5791ff88; background: linear-gradient(145deg, #2b5cad, #183b74); color: white; box-shadow: 0 8px 22px #132f635c; }

.metrics {
  display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 12px;
}
.metrics div {
  min-height: 88px; border: 1px solid var(--line); border-radius: 17px; padding: 14px;
  background: linear-gradient(145deg, #182337, #111927); box-shadow: var(--shadow);
}
.metrics span { color: var(--muted); font-size: 12px; }
.metrics b { display: block; margin-top: 7px; font-size: 21px; letter-spacing: -.02em; }

#filters, .table {
  border: 1px solid var(--line); border-radius: 18px; background: #111827e8; box-shadow: var(--shadow);
}
#filters { margin-bottom: 12px; padding: 12px; }
.search { display: flex; gap: 7px; }
.search input {
  min-width: 0; flex: 1; border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  outline: none; background: #0d1422; color: var(--text);
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #4f8cff20; }
.search input::placeholder { color: #64748b; }
.search button, .primary {
  border: 0; border-radius: 12px; background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  color: white; font-weight: 800;
}
.search button { padding: 0 15px; }
.chips { display: flex; gap: 7px; overflow-x: auto; padding-top: 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip, .toolbar button {
  white-space: nowrap; border: 1px solid var(--line); border-radius: 999px; padding: 8px 11px;
  background: #172133; color: var(--muted);
}
.chip.active, .toolbar .active { border-color: #5b92ff; background: #254f91; color: white; }

.table { overflow: visible; border: 0; background: transparent; box-shadow: none; }
.row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 15px;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border: 0; }
.name { font-weight: 760; overflow-wrap: anywhere; }
.sub { margin-top: 5px; color: var(--muted); font-size: 12px; }
.count { text-align: right; font-weight: 800; }
.badge {
  display: block; width: max-content; max-width: 150px; margin: 6px 0 0 auto; padding: 4px 8px;
  border: 1px solid #ff7a8450; border-radius: 999px; background: #541f2a80; color: #ff9ca4; font-size: 10px;
}
.empty { padding: 34px 22px; text-align: center; color: var(--muted); }
.error, .negative { color: var(--danger); }
.positive { color: var(--success); }

footer {
  position: fixed; z-index: 10; right: 0; bottom: 0; left: 0; display: flex; gap: 8px;
  justify-content: center; padding: 11px 12px calc(11px + env(safe-area-inset-bottom));
  border-top: 1px solid #273249cc; background: #090d17e8; backdrop-filter: blur(18px);
}
footer button { border: 0; border-radius: 13px; padding: 13px 16px; font-weight: 800; }
.primary { flex: 1; max-width: 440px; }
.secondary { background: #1b2639; color: var(--text); }
#toast { position: fixed; z-index: 30; right: 16px; bottom: 86px; left: 16px; max-width: 440px; margin: auto; padding: 12px 15px; border: 1px solid #4f8cff66; border-radius: 13px; background: #17243b; color: white; text-align: center; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(12px); transition: .2s ease; }
#toast.visible { opacity: 1; transform: translateY(0); }

@media (max-width: 420px) {
  .app { padding-right: 9px; padding-left: 9px; }
  nav { margin-right: -9px; margin-left: -9px; padding-right: 9px; padding-left: 9px; }
  .row { padding: 13px; }
  .metrics b { font-size: 19px; }
}
