:root {
  --bg: #0e0f14; --panel: #181a22; --panel2: #232634; --line: #2c3040; --text: #f2f4fa; --muted: #8e94a8;
  --accent: #5b7cff; --accent2: #a24bff; --on-accent: #fff;
  --grad: linear-gradient(135deg, #2f8bff 0%, #6d5cff 55%, #a24bff 100%);
  --green: #3ddc84; --red: #ff5a5f; --yellow: #ffd25a; --blue: #4aa3ff;
  --radius: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.35 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: 76px; max-width: 560px; margin: 0 auto; }
button { font: inherit; color: inherit; border: 0; border-radius: 10px; padding: 9px 12px; background: var(--panel2); cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--grad); color: var(--on-accent); font-weight: 700; }
button.green { background: var(--green); color: #07240f; font-weight: 700; }
button.red { background: var(--red); color: #fff; font-weight: 700; }
button.small { padding: 6px 9px; font-size: 13px; }
input, select { font: inherit; color: var(--text); background: var(--bg); outline-color: var(--accent); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; }
h2 { font-size: 18px; margin: 4px 0 10px; }
h3 { font-size: 15px; margin: 0 0 6px; }
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 10px 12px; }

/* Шапка */
.balances { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: auto 1fr 1fr 1fr auto; gap: 6px;
  padding: 10px 12px; background: rgba(14,15,20,.92); border-bottom: 1px solid var(--line); backdrop-filter: blur(6px); }
.bal { background: var(--panel); border-radius: 10px; padding: 6px 8px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; }
.bal b { display: block; font-size: 14px; }
.bal span { font-size: 11px; color: var(--muted); }
.indicators { display: flex; gap: 6px; padding: 8px 12px 0; flex-wrap: wrap; }
.ind { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 12px; font-variant-numeric: tabular-nums; }
.ind.ok { border-color: #1f5e3d; } .ind.bad { border-color: var(--red); color: #ff9a9d; }

/* Плашка Россетей */
.alert { margin: 10px 12px; padding: 12px; border-radius: var(--radius); font-weight: 600; }
.alert.yellow { background: var(--panel); border: 2px solid var(--yellow); box-shadow: 0 0 0 0 rgba(255,210,90,.6); animation: blinkY 1s infinite; }
.alert.red { background: var(--panel); border: 2px solid var(--red); box-shadow: 0 0 0 0 rgba(255,90,95,.7); animation: blinkR .5s infinite; }
.alert.gray { background: var(--panel2); border: 1px solid var(--line); }
@keyframes blinkY { 50% { border-color: #fff1b8; box-shadow: 0 0 16px 3px rgba(255,210,90,.75); } }
@keyframes blinkR { 50% { border-color: #ffd0d2; box-shadow: 0 0 18px 4px rgba(255,90,95,.85); background: #3a1420; } }
.alert button { margin-top: 8px; width: 100%; }

/* Локации */
.tabs { display: flex; gap: 6px; padding: 10px 12px 0; overflow-x: auto; }
.tab { white-space: nowrap; background: var(--panel); border: 1px solid var(--line); }
.tab.active { background: var(--grad); color: var(--on-accent); font-weight: 700; border-color: transparent; }

.loadbar { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.loadbar i { display: block; height: 100%; background: var(--green); }
.loadbar i.warn { background: var(--yellow); } .loadbar i.over { background: var(--red); }

/* Асики */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 10px 12px; }
.asic { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.asic.broken { border-color: var(--red); }
.asic svg { width: 100%; height: 130px; display: block; }
.asic .name { font-weight: 700; font-size: 13px; }
.asic .stat { font-size: 12px; color: var(--muted); }
.asic .btns { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.asic .btns button { padding: 6px 4px; font-size: 12px; }
.wear { height: 5px; background: var(--bg); border-radius: 9px; overflow: hidden; }
.wear i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), var(--yellow), var(--red)); background-size: 300% 100%; }
.fan { transform-box: fill-box; transform-origin: center; }
.fan.spin { animation: spin .45s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.led { transition: fill .3s; }

/* Магазин */
.shopitem { display: flex; gap: 10px; align-items: center; }
.shopitem .info { flex: 1; }
.badge { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 99px; background: var(--panel2); color: var(--muted); }
.badge.good { background: #153a29; color: #7de8a9; }

/* Биржа */
.rate { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; margin: 4px 0; }
.youget { font-size: 17px; margin: 10px 0; }
.youget b { color: var(--green); }

/* Навигация */
nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: grid; grid-template-columns: repeat(8, 1fr);
  background: rgba(20,22,30,.97); backdrop-filter: blur(8px); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; }
nav button { background: none; padding: 4px 0; font-size: 9.5px; letter-spacing: -.2px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative; }
nav button .ico { font-size: 20px; line-height: 1; }
nav button.active { color: #8ea2ff; }
nav button .dot { position: absolute; top: 0; right: 22%; width: 9px; height: 9px; border-radius: 9px; background: var(--red); }

.log { font-size: 13px; }
.log div { padding: 6px 0; border-bottom: 1px solid var(--line); }
.log .bad { color: #ff9a9d; } .log .good { color: #8fe9b4; }
.log time { color: var(--muted); font-size: 11px; margin-right: 6px; }

#toast { position: fixed; left: 50%; bottom: 86px; transform: translateX(-50%); background: #000d; color: #fff; padding: 10px 14px;
  border-radius: 12px; max-width: 90%; font-size: 14px; z-index: 10; opacity: 0; transition: opacity .25s; pointer-events: none; }
#toast.show { opacity: 1; }
.empty { text-align: center; padding: 30px 20px; color: var(--muted); }
.kv { display: flex; justify-content: space-between; padding: 4px 0; font-variant-numeric: tabular-nums; }
.asic .btns select { padding: 6px 4px; font-size: 12px; border-radius: 10px; }

.rs-logo { display: block; height: 30px; width: auto; background: #fff; border-radius: 8px; padding: 5px 9px; margin-bottom: 8px; }
.rs-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 18px; font-weight: 700; }
.rs-head .rs-logo { margin: 0; height: 34px; }

/* Топ-100 */
.toprow { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.toprow:last-child { border-bottom: 0; }
.toprow .pl { width: 32px; text-align: center; font-weight: 800; }
.toprow .av { width: 34px; height: 34px; border-radius: 10px; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 800; flex: none; }
.toprow .tx { flex: 1; min-width: 0; }
.toprow .tx b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toprow .tx span { font-size: 12px; color: var(--muted); }
.toprow .val { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.toprow.mine { background: var(--panel2); border-radius: 10px; outline: 2px solid var(--accent); }

/* ---------- Анимации ---------- */
button { transition: transform .1s ease, filter .15s ease, opacity .2s; }
button:active:not(:disabled) { transform: scale(.97); }
.snd { align-self: stretch; padding: 0 10px; font-size: 18px; background: var(--panel); }
.loadbar i, .wear i { transition: width .6s ease, background-color .3s; }
nav button .ico { transition: transform .2s ease; }
nav button.active .ico { transform: translateY(-2px) scale(1.18); }

/* появление экрана при смене вкладки */
#screen.enter > * { animation: rise .35s ease both; }
#screen.enter > *:nth-child(2) { animation-delay: .04s; } #screen.enter > *:nth-child(3) { animation-delay: .08s; }
#screen.enter > *:nth-child(4) { animation-delay: .12s; } #screen.enter > *:nth-child(5) { animation-delay: .16s; }
#screen.enter > *:nth-child(n+6) { animation-delay: .2s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* новый асик */
.asic.pop { animation: pop .5s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes pop { from { opacity: 0; transform: scale(.7); } to { opacity: 1; transform: none; } }
/* работающий асик слегка светится */
.asic.working { border-color: #2f8f62; }
@keyframes glow { 50% { border-color: #2f8f62; box-shadow: 0 0 14px -2px rgba(61,220,132,.35); } }

/* баланс: подсветка и всплывающая сумма */
.bal b.flash-up { animation: flashUp .8s ease; } .bal b.flash-down { animation: flashDown .8s ease; }
@keyframes flashUp { 30% { color: var(--green); transform: scale(1.12); text-shadow: 0 0 10px rgba(61,220,132,.7); } }
@keyframes flashDown { 30% { color: var(--red); transform: scale(.94); } }
.bal b { transform-origin: left center; }
.floaty { position: fixed; top: 58px; left: 16px; z-index: 12; font-weight: 800; font-size: 18px; pointer-events: none; animation: floatUp 1.2s ease-out forwards; text-shadow: 0 2px 8px #000a; }
.floaty.up { color: var(--green); } .floaty.down { color: var(--red); }
@keyframes floatUp { from { opacity: 0; transform: translateY(8px) scale(.9); } 15% { opacity: 1; } to { opacity: 0; transform: translateY(-34px) scale(1.1); } }

#toast { transform: translate(-50%, 14px); transition: opacity .25s, transform .25s; }
#toast.show { transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

.logo { width: 38px; height: 38px; border-radius: 50%; align-self: center; flex: none; }
#phoneIn { width: 100%; margin: 6px 0; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); font: inherit; }

.who { background: var(--panel); border-radius: 10px; padding: 6px 10px; max-width: 96px; min-width: 56px; overflow: hidden; align-self: stretch; }
.who span { display: block; font-size: 11px; color: var(--muted); }
.who b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
