:root {
  --bg: #17080e;
  --bg2: #26101a;
  --card: rgba(255, 255, 255, .035);
  --card-solid: #231019;
  --border: rgba(255, 110, 140, .16);
  --border-strong: rgba(255, 110, 140, .38);
  --text: #fff1f4;
  --muted: #c98b9c;
  --accent: #ff4d6d;
  --accent-soft: rgba(255, 77, 109, .16);
  --accent-text: #ff8fa3;
  --warn: #ffb020;
  --warn-soft: rgba(255, 176, 32, .1);
  --ok: #ff8fa3;
  --track: rgba(255, 255, 255, .09);
  --nav: rgba(30, 12, 20, .82);
  --btn-fg: #2a0610;
  --shadow: 0 10px 40px rgba(0, 0, 0, .35);
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}
:root[data-theme="light"] {
  --bg: #fff4f6;
  --bg2: #ffe3ea;
  --card: rgba(255, 255, 255, .75);
  --card-solid: #fff;
  --border: rgba(214, 51, 92, .18);
  --border-strong: rgba(214, 51, 92, .4);
  --text: #2b0f18;
  --muted: #9a5a6c;
  --accent: #e11d48;
  --accent-soft: rgba(225, 29, 72, .1);
  --accent-text: #be123c;
  --warn: #b45309;
  --warn-soft: rgba(245, 158, 11, .12);
  --ok: #be123c;
  --track: rgba(0, 0, 0, .08);
  --nav: rgba(255, 255, 255, .88);
  --btn-fg: #fff;
  --shadow: 0 10px 30px rgba(190, 18, 60, .12);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
svg.i { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* --- фон --- */
.aurora {
  position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(255, 46, 99, .22), transparent 60%),
    radial-gradient(700px 500px at -10% 40%, rgba(160, 20, 70, .22), transparent 60%),
    radial-gradient(800px 600px at 60% 110%, rgba(255, 77, 109, .14), transparent 60%),
    linear-gradient(180deg, var(--bg), var(--bg2));
}
:root[data-theme="light"] .aurora {
  background:
    radial-gradient(800px 500px at 90% -10%, rgba(255, 120, 150, .35), transparent 60%),
    radial-gradient(700px 500px at -10% 50%, rgba(255, 180, 200, .4), transparent 60%),
    linear-gradient(180deg, var(--bg), var(--bg2));
}
.stars { position: fixed; inset: 0; z-index: -1; pointer-events: none; }
.stars i { position: absolute; width: 2px; height: 2px; border-radius: 50%; background: #ffd0da; opacity: .5; animation: tw 4s ease-in-out infinite; }
:root[data-theme="light"] .stars { display: none; }
@keyframes tw { 50% { opacity: .05; transform: scale(.6); } }

/* --- каркас --- */
#app { max-width: 560px; margin: 0 auto; padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
.header {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 6px;
  padding: 10px 12px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 70%, transparent); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; font-weight: 700; font-size: 17px; }
.brand img { width: 36px; height: 36px; border-radius: 11px; border: 1px solid var(--border); }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbtn {
  height: 36px; min-width: 36px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--card); color: var(--accent-text); font-weight: 700; font-size: 13px;
}
.hbtn .dot { position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.flag { width: 18px; height: 12px; border-radius: 2px; background: linear-gradient(#fff 33%, #1c57a5 33% 66%, #d52b1e 66%); }
.flag.en { background: linear-gradient(135deg, #1c3f94 50%, #d52b1e 50%); }

.page { padding: 18px 16px 0; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }
h1 { margin: 0 0 4px; font-size: 28px; line-height: 1.15; font-weight: 800; letter-spacing: -.02em; }
h2 { margin: 0; font-size: 19px; font-weight: 700; }
.sub { color: var(--accent-text); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--accent-soft); color: var(--accent-text); font-size: 13px; font-weight: 600; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--accent-text); margin-bottom: 8px; font-weight: 600; }

/* --- карточки --- */
.card {
  position: relative; border: 1px solid var(--border); border-radius: 24px; background: var(--card);
  padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.card.flat { box-shadow: none; border-radius: 18px; }
.card.click { cursor: pointer; transition: transform .12s, border-color .12s; }
.card.click:active { transform: scale(.985); border-color: var(--border-strong); }
.tile { display: flex; align-items: center; gap: 14px; }
.ico { width: 46px; height: 46px; border-radius: 14px; background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; flex: none; }
.ico.warn { background: var(--warn-soft); color: var(--warn); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.grid2 .card { margin: 0; padding: 14px; border-radius: 18px; }
.lbl { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; font-family: var(--mono); }
.big { font-size: 26px; font-weight: 800; }

/* --- статус / трафик --- */
.status { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-weight: 600; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.status .d { width: 9px; height: 9px; border-radius: 50%; background: var(--accent-text); box-shadow: 0 0 10px var(--accent); }
.status.warn .d { background: var(--warn); box-shadow: 0 0 10px var(--warn); }
.pill { padding: 3px 9px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--accent-soft); color: var(--accent-text); font-size: 10.5px; }
.pct { font-size: 46px; font-weight: 800; line-height: 1; text-align: right; }
.pct small { font-size: 20px; color: var(--accent-text); }
.bar { position: relative; height: 14px; border-radius: 999px; background: var(--track); margin: 18px 0 8px; overflow: hidden; }
.bar > b { position: absolute; inset: 0 auto 0 0; min-width: 14px; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-text)); transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.bar > s { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(255, 255, 255, .12); }
.ticks { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11.5px; font-weight: 600; margin-bottom: 14px; }
.device { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--border-strong); border-radius: 18px; background: var(--accent-soft); margin-bottom: 12px; }
.device.full { background: transparent; opacity: .72; }
.device .t { font-weight: 700; font-size: 16px; }
.device .s { font-size: 12.5px; color: var(--muted); }
.device .w { font-size: 12px; color: var(--warn); }
.dots { margin-left: auto; display: flex; gap: 6px; }
.dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); opacity: .6; }
.dots i.off { background: var(--track); opacity: 1; }
.timer { display: flex; align-items: baseline; gap: 6px; font-weight: 800; font-size: 30px; color: var(--warn); }
.timer small { font-size: 14px; }
.timer .c { opacity: .5; }
.warnbox { border: 1px solid rgba(255, 176, 32, .4); background: var(--warn-soft); border-radius: 18px; padding: 14px; }
.linkrow { display: flex; gap: 10px; margin-bottom: 12px; }
.linkrow .url { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 13px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--card); font-family: var(--mono); font-size: 13px; }
.sq { display: inline-block; margin: 6px 8px 0 0; padding: 6px 12px; border-radius: 10px; background: var(--card); border: 1px solid var(--border); font-size: 13px; color: var(--muted); }

/* --- кнопки и поля --- */
.btn {
  width: 100%; padding: 14px 18px; border-radius: 14px; background: var(--accent); color: var(--btn-fg);
  font-weight: 700; font-size: 15px; text-align: center; transition: filter .12s, transform .12s; display: block;
}
.btn:active { transform: scale(.98); filter: brightness(.92); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.ghost { background: var(--accent-soft); color: var(--accent-text); border: 1px solid var(--border-strong); }
.iconbtn { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; border: 1px solid var(--border); background: var(--card); color: var(--accent-text); flex: none; }
.link { color: var(--accent-text); font-weight: 600; font-size: 14px; display: inline-flex; gap: 6px; align-items: center; }
.input {
  width: 100%; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--border); background: var(--card);
  outline: none; margin-bottom: 12px; font-size: 15px;
}
.input:focus { border-color: var(--border-strong); }
.input::placeholder { color: var(--muted); opacity: .7; }

/* --- списки --- */
.method { padding: 16px; border: 1px solid var(--border); border-radius: 18px; margin-bottom: 12px; cursor: pointer; background: var(--card); }
.method:active { border-color: var(--border-strong); }
.method b { font-size: 16px; }
.method p { margin: 4px 0 8px; color: var(--muted); font-size: 14px; }
.method em { font-style: normal; color: var(--accent-text); font-size: 12.5px; font-weight: 600; }
.acc > summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 17px; }
.acc > summary::-webkit-details-marker { display: none; }
.acc[open] .chev { transform: rotate(180deg); }
.chev { transition: transform .2s; }
.hist { display: flex; justify-content: space-between; gap: 10px; padding: 11px 0; border-top: 1px solid var(--border); font-size: 14px; }
.hist small { color: var(--muted); display: block; font-size: 12px; }
.pos { color: #7be0a0; font-weight: 700; } .neg { color: var(--accent-text); font-weight: 700; }
.dev { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 16px; background: var(--card); margin-top: 10px; }
.dev .n { font-weight: 700; } .dev .p { color: var(--muted); font-size: 12.5px; font-family: var(--mono); }
.prize { display: flex; align-items: center; gap: 14px; padding: 12px 14px 12px 0; margin-bottom: 8px; border: 1px solid var(--border); border-radius: 14px; background: var(--card); font-weight: 600; overflow: hidden; }
.prize i { width: 4px; align-self: stretch; border-radius: 0 4px 4px 0; }
.prize span.e { font-size: 22px; }
.tariff { margin-bottom: 12px; }
.tariff .price { font-size: 24px; font-weight: 800; color: var(--accent-text); }
.tariff ul { margin: 10px 0 14px; padding: 0; list-style: none; color: var(--muted); font-size: 14px; display: grid; gap: 4px; }

/* --- колесо --- */
.wheel-wrap { position: relative; width: min(92%, 340px); aspect-ratio: 1; margin: 14px auto 18px; }
.wheel-wrap canvas { width: 100%; height: 100%; display: block; transition: transform 5s cubic-bezier(.12, .7, .08, 1); filter: drop-shadow(0 8px 24px rgba(168, 85, 247, .35)); }
.pointer { position: absolute; top: -12px; left: 50%; width: 38px; height: 46px; transform: translateX(-50%); z-index: 3; filter: drop-shadow(0 3px 6px rgba(0, 0, 0, .5)); }
.hub { position: absolute; left: 50%; top: 50%; width: 22%; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; background: radial-gradient(circle at 35% 30%, #6d5dfc, #2f2a86); border: 4px solid #8b7bff; display: grid; place-items: center; font-weight: 800; font-size: 12px; letter-spacing: .1em; color: #cfd0ff; z-index: 2; box-shadow: 0 0 20px rgba(109, 93, 252, .6); }
.cost { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; margin-bottom: 14px; text-align: center; }
.cost div { padding: 12px 6px; font-size: 14px; }
.cost div.on { background: var(--accent-soft); }
.cost small { display: block; color: var(--accent-text); font-size: 12px; margin-bottom: 2px; }

/* --- навигация --- */
.nav {
  position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); max-width: 540px; margin: 0 auto; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; padding: 6px; border-radius: 24px;
  background: var(--nav); border: 1px solid var(--border); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); box-shadow: var(--shadow);
}
.nav button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 2px 8px; border-radius: 18px; color: var(--muted); font-size: 11.5px; font-weight: 600; border: 1px solid transparent; }
.nav button svg { width: 22px; height: 22px; }
.nav button.on { color: var(--accent-text); background: var(--accent-soft); border-color: var(--border-strong); }

/* --- шторка / тост --- */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fadein .2s; }
@keyframes fadein { from { opacity: 0; } }
.sheet { width: 100%; max-width: 560px; background: var(--card-solid); border: 1px solid var(--border); border-radius: 26px 26px 0 0; padding: 20px 18px calc(22px + env(safe-area-inset-bottom)); animation: up .25s cubic-bezier(.2, .8, .2, 1); max-height: 88vh; overflow: auto; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet h3 { margin: 0 0 12px; font-size: 20px; }
.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.presets button { padding: 11px 0; border: 1px solid var(--border); border-radius: 12px; background: var(--card); font-weight: 700; }
.presets button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.menu a, .menu button { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 4px; font-weight: 600; border-top: 1px solid var(--border); text-align: left; }
.menu > :first-child { border-top: 0; }
.toast { position: fixed; left: 50%; top: 14px; transform: translate(-50%, -80px); z-index: 99; max-width: 90%; padding: 12px 18px; border-radius: 14px; background: var(--card-solid); border: 1px solid var(--border-strong); box-shadow: var(--shadow); font-weight: 600; transition: transform .3s; text-align: center; }
.toast.show { transform: translate(-50%, 0); }
.toast.err { border-color: #ff4d6d; }
.boot { display: grid; place-items: center; height: 70vh; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--track); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.prize-pop { text-align: center; padding: 10px 0 4px; }
.prize-pop .e { font-size: 64px; }
.prize-pop h3 { font-size: 24px; margin: 8px 0 18px; }

/* --- админка --- */
.fld { display: block; margin-bottom: 10px; }
.fld > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.fld .input { margin-bottom: 0; }
select.input { appearance: none; background-image: none; }
select.input option { background: var(--card-solid); color: var(--text); }
textarea.input { font-family: var(--font); margin-bottom: 12px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 14px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; padding: 9px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); font-weight: 600; font-size: 13.5px; white-space: nowrap; }
.chips button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
