:root {
  --bg: #0E0B16;
  --card: #171221;
  --line: #251D33;
  --inset: #120E1A;
  --divider: #221B2E;
  --chip: #251D33;
  --seg-on: #2E2440;
  --text: #F3EFFA;
  --muted: #9B91B0;
  --soft: #CFC7DD;
  --dim: #8C82A1;
  --accent: #8B5CF6;
  --accent-strong: #7C3AED;
  --accent-text: #C4B1FF;
  --green: #4ADE80;
  --yellow: #FBBF24;
  --red: #F87171;
  --display: 'Unbounded', sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: 'Onest', system-ui, sans-serif; font-variant-numeric: tabular-nums;
  overflow: hidden;
}
button, input { font-family: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; padding: 0; }
a { color: var(--accent-text); text-decoration: none; }
.scroll { scrollbar-width: none; } .scroll::-webkit-scrollbar { display: none; }
.hidden { display: none !important; }
.pos { color: var(--green); } .neg { color: var(--red); } .warn { color: var(--yellow); }
.muted { color: var(--muted); }

#screen {
  position: fixed; inset: 0 0 calc(78px + env(safe-area-inset-bottom)) 0; overflow-y: auto;
  padding: 20px 16px 24px; display: flex; flex-direction: column; gap: 14px;
}
h1 { margin: 0; font-family: var(--display); font-size: 24px; font-weight: 700; }
h2 { margin: 0; font-size: 16px; font-weight: 700; }
.head { display: flex; align-items: center; justify-content: space-between; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.inset { background: var(--inset); border-radius: 14px; padding: 12px; }
.empty { color: var(--muted); text-align: center; padding: 28px 16px; }

.run { min-height: 38px; padding: 0 14px 0 12px; border-radius: 999px; font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.run i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.run.on { background: rgba(74,222,128,0.14); color: var(--green); }
.run.off { background: var(--chip); color: var(--soft); }

.trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; text-align: center; }
.big { font-family: var(--display); font-size: 22px; font-weight: 600; }
.cap { font-size: 12px; color: var(--muted); margin-top: 2px; }
.bar { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar > div { height: 100%; border-radius: 999px; background: var(--accent); }
.limit { display: flex; flex-direction: column; gap: 7px; }
.limit .row { display: flex; justify-content: space-between; font-size: 13px; }
.mkts { display: flex; gap: 6px; }
.mkts div { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 0; border-radius: 10px; background: var(--inset); font-size: 12px; font-weight: 600; }
.mkts span { color: var(--muted); font-weight: 500; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 0 16px; flex-shrink: 0; }
.chips button { flex-shrink: 0; min-height: 36px; padding: 0 16px; border-radius: 999px; background: var(--card); color: var(--soft); font-size: 14px; font-weight: 600; }
.chips button.on { background: var(--accent); color: #fff; }

.seg { display: grid; gap: 4px; padding: 4px; border-radius: 14px; background: var(--card); flex-shrink: 0; }
.seg button { min-height: 40px; border-radius: 11px; color: var(--muted); font-size: 14px; font-weight: 600; }
.seg button.on { background: var(--seg-on); color: var(--text); }
.seg.dark { background: var(--inset); }

.gift { border-radius: 16px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; position: relative; }
.gift img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.gift svg { width: 50%; height: 50%; }

.top { display: flex; align-items: center; gap: 12px; }
.top .info { flex: 1; min-width: 0; }
.name { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.name span { color: var(--muted); font-weight: 500; }
.sub { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 13px; color: var(--muted); }
.disc { font-family: var(--display); font-size: 24px; font-weight: 700; }
.attrs { font-size: 13px; color: var(--muted); }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.lbl { font-size: 12px; color: var(--muted); }
.val { font-size: 16px; font-weight: 700; margin-top: 2px; }
.val small { font-size: 12px; }
.meta { display: flex; align-items: center; justify-content: space-between; }
.meta .stats { display: flex; gap: 12px; font-size: 13px; color: var(--muted); }
.meta .stats span { display: flex; align-items: center; gap: 5px; }
.badge { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; max-width: 60%; overflow: hidden; text-overflow: ellipsis; }
.b-found { background: rgba(139,92,246,0.18); color: var(--accent-text); }
.b-ok { background: rgba(74,222,128,0.14); color: var(--green); }
.b-offer { background: rgba(251,191,36,0.14); color: var(--yellow); }
.b-gray { background: #231B30; color: var(--dim); }
.b-err { background: rgba(248,113,113,0.14); color: var(--red); }

.acts { display: flex; gap: 8px; }
.btn { min-height: 48px; padding: 0 16px; border-radius: 14px; font-size: 15px; font-weight: 600; display: flex; align-items: center; justify-content: center; background: var(--chip); color: var(--text); }
.btn.primary { flex: 1; background: var(--accent-strong); color: #fff; font-weight: 700; }
.btn.danger { background: rgba(248,113,113,0.12); color: var(--red); }
.btn.sm { min-height: 40px; padding: 0 14px; border-radius: 12px; font-size: 14px; }
.btn.icon { width: 48px; padding: 0; color: var(--soft); }
.btn.dashed { border: 1.5px dashed #3A2F4F; background: transparent; color: var(--accent-text); gap: 8px; }
.btn.block { width: 100%; min-height: 54px; border-radius: 16px; font-size: 16px; }
.btn:disabled { opacity: .5; }

.split { display: flex; align-items: center; justify-content: space-between; }
.timer { flex: 1; display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.timer.soon { color: var(--red); }

.flow { flex: 1; display: flex; align-items: center; gap: 8px; padding: 0 12px; min-height: 44px; border-radius: 12px; background: var(--inset); font-size: 14px; }
.list { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 4px 0; }
.list button { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-align: left; min-height: 64px; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px; }
.tile .v { font-size: 20px; font-weight: 700; margin-top: 6px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; text-align: center; }
.kpis b { font-size: 17px; }
.kpis div div { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.mrow { display: grid; grid-template-columns: 1.4fr 1fr 1fr 0.8fr; align-items: center; min-height: 40px; font-size: 14px; border-top: 1px solid var(--divider); }
.topc .r { display: flex; justify-content: space-between; font-size: 14px; }
.topc .bar { background: var(--divider); margin-top: 6px; }

.sec { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 6px 16px; }
.sec-h { display: flex; align-items: center; justify-content: space-between; min-height: 52px; }
.srow { display: flex; justify-content: space-between; align-items: center; min-height: 50px; border-top: 1px solid var(--divider); font-size: 15px; width: 100%; text-align: left; gap: 12px; }
.srow .v { color: var(--muted); text-align: right; }
.srange { border-top: 1px solid var(--divider); padding: 14px 0 12px; }
.srange .r { display: flex; justify-content: space-between; font-size: 15px; }
.srange .r span { color: var(--accent-text); font-weight: 700; }
input[type=range] { width: 100%; margin: 12px 0 0; accent-color: var(--accent); }
.switch { width: 50px; height: 30px; border-radius: 999px; padding: 3px; background: var(--chip); display: flex; justify-content: flex-start; flex-shrink: 0; transition: background .15s; }
.switch span { width: 24px; height: 24px; border-radius: 50%; background: #fff; display: block; }
.switch.on { background: var(--accent); justify-content: flex-end; }
.pills { display: flex; gap: 6px; }
.pills button { min-height: 34px; padding: 0 12px; border-radius: 999px; background: var(--chip); color: var(--muted); font-size: 13px; font-weight: 600; }
.pills button.on { background: var(--accent); color: #fff; }

#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
  padding: 8px 4px calc(10px + env(safe-area-inset-bottom)); background: var(--inset); border-top: 1px solid #231B30; z-index: 5;
}
#tabbar button { display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 48px; color: var(--dim); font-size: 10px; font-weight: 600; }
#tabbar button span { width: 46px; height: 30px; border-radius: 999px; display: flex; align-items: center; justify-content: center; }
#tabbar button.on { color: var(--accent-text); }
#tabbar button.on span { background: rgba(139,92,246,0.22); }

/* overlays */
#overlay { position: fixed; inset: 0; z-index: 20; }
.dim { position: absolute; inset: 0; background: rgba(6,4,10,0.7); }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; background: var(--card); border-radius: 28px 28px 0 0; border-top: 1px solid #2A2238;
  padding: 10px 20px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 18px; max-height: 92vh; overflow-y: auto;
}
.grab { width: 40px; height: 5px; border-radius: 999px; background: #3A3148; align-self: center; }
.close { width: 40px; height: 40px; border-radius: 50%; background: var(--chip); color: var(--soft); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.hero { text-align: center; padding: 6px 0; }
.hero .p { font-family: var(--display); font-size: 40px; font-weight: 700; margin-top: 6px; }
.hero .p span { font-size: 18px; color: var(--muted); }
.pill-res { display: inline-flex; margin-top: 10px; padding: 6px 12px; border-radius: 999px; font-size: 14px; font-weight: 700; }
.pill-res.good { background: rgba(74,222,128,0.14); color: var(--green); }
.pill-res.bad { background: rgba(248,113,113,0.14); color: var(--red); }
.quick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.quick button { min-height: 38px; border-radius: 12px; background: var(--chip); color: var(--soft); font-size: 14px; font-weight: 600; }
.quick button.on { background: var(--accent); color: #fff; }

.page { position: absolute; inset: 0; background: var(--bg); display: flex; flex-direction: column; }
.page-h { flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding: 14px 12px 6px; }
.page-h h1 { font-size: 20px; }
.back { width: 44px; height: 44px; border-radius: 50%; color: var(--soft); display: flex; align-items: center; justify-content: center; }
.page-b { flex: 1; overflow-y: auto; padding: 8px 16px 16px; display: flex; flex-direction: column; gap: 16px; }
.page-f { flex-shrink: 0; padding: 14px 16px calc(20px + env(safe-area-inset-bottom)); background: var(--inset); border-top: 1px solid #231B30; display: flex; flex-direction: column; gap: 12px; }
.fld { display: flex; flex-direction: column; gap: 8px; }
.fld label, .fld > span { font-size: 13px; color: var(--muted); }
.fld input { height: 50px; border-radius: 14px; border: 1px solid #2A2238; background: var(--card); color: var(--text); font-size: 17px; font-weight: 600; padding: 0 14px; width: 100%; }
.fld input.xl { height: 56px; font-size: 22px; font-weight: 700; padding: 0 16px; }
.fld input:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.mk3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.mk3 button { min-height: 42px; border-radius: 12px; background: var(--card); color: var(--soft); font-size: 14px; font-weight: 600; }
.mk3 button.on { background: var(--accent); color: #fff; }
.result { display: flex; justify-content: space-between; align-items: flex-end; }
.result .r { font-family: var(--display); font-size: 20px; font-weight: 700; margin-top: 2px; }

#toast { position: fixed; left: 16px; right: 16px; bottom: calc(92px + env(safe-area-inset-bottom)); background: #2A2238; color: var(--text);
  padding: 12px 14px; border-radius: 14px; z-index: 40; font-size: 14px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.4); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { padding: 5px 10px; border-radius: 999px; background: var(--inset); color: var(--soft); font-size: 12px; font-weight: 600; }
.tag b { color: var(--muted); font-weight: 600; }
.tag.rare { background: rgba(139,92,246,0.18); color: var(--accent-text); }
.tag.rare b { color: var(--accent-text); }
