:root {
  color-scheme: dark;
  --bg: #050d1f;
  --panel: rgba(6, 16, 38, 0.82);
  --panel-2: rgba(10, 24, 52, 0.92);
  --line: rgba(54, 217, 255, 0.35);
  --line-soft: rgba(54, 217, 255, 0.16);
  --text: #eaf6ff;
  --muted: #8fb3cc;
  --cyan: #36d9ff;
  --yellow: #ffd23f;
  --pink: #ff5d9e;
  --lime: #7ce87c;
  --red: #ff6161;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }


html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- loader ---------- */
.loader {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background:
    radial-gradient(circle at 50% 0%, rgba(54, 217, 255, 0.14), transparent 40rem),
    var(--bg);
}
.loader__img {
  width: 120px;
  height: 120px;
  border-radius: 18px;
  border: 2px solid var(--line);
  box-shadow: 0 0 34px rgba(54, 217, 255, 0.4);
  image-rendering: pixelated;
  animation: bob 1.6s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateY(-8px); } }
.loader__text { color: var(--muted); font-size: 14px; letter-spacing: 0.4px; }
.dots::after { content: ""; animation: dots 1.4s steps(4, end) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

/* ---------- app shell ---------- */
.app {
  max-width: 560px;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 14px calc(86px + env(safe-area-inset-bottom));
}

.page { display: grid; gap: 12px; }
.page--center { justify-items: center; text-align: center; padding-top: 12vh; }

.page--hero {
  position: relative;
}
body[data-page="home"] {
  background:
    linear-gradient(rgba(5, 13, 31, 0.55), rgba(5, 13, 31, 0.88) 55%, var(--bg) 82%),
    url("./assets/background-home-hero.jpg") top center / cover no-repeat fixed;
}
body[data-page="balance"], body[data-page="models"], body[data-page="pay"], body[data-page="profile"] {
  background:
    linear-gradient(rgba(5, 13, 31, 0.72), rgba(5, 13, 31, 0.92) 60%, var(--bg) 85%),
    url("./assets/background-sections-clean.jpg") top center / cover no-repeat fixed;
}
body[data-page="admin"] {
  background:
    linear-gradient(rgba(5, 13, 31, 0.7), rgba(5, 13, 31, 0.93) 60%, var(--bg) 85%),
    url("./assets/background-admin-dashboard.jpg") top center / cover no-repeat fixed;
}

.page__title {
  margin: 6px 0 2px;
  font-size: 26px;
  letter-spacing: 0.5px;
  text-shadow: 0 0 18px rgba(54, 217, 255, 0.55);
}

/* ---------- hero ---------- */
.hero { text-align: center; padding: 8px 0 2px; }
.hero__avatar {
  width: 108px;
  height: 108px;
  border-radius: 16px;
  border: 2px solid var(--line);
  box-shadow: 0 0 30px rgba(54, 217, 255, 0.45);
  image-rendering: pixelated;
}
.hero__title {
  margin: 10px 0 4px;
  font-size: 34px;
  letter-spacing: 1px;
  text-shadow: 0 0 22px rgba(54, 217, 255, 0.7);
}
.hero__sub { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }

/* ---------- panels (pixel corners) ---------- */
.panel {
  position: relative;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(14px);
  padding: 14px;
  clip-path: polygon(0 8px, 8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px));
}
.panel__title {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--cyan);
}

.panel--status { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { text-align: center; padding: 4px 2px; }
.stat__label { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
.stat__value { display: block; margin-top: 5px; font-size: 19px; }
.stat__value--yellow { color: var(--yellow); text-shadow: 0 0 14px rgba(255, 210, 63, 0.5); }

.usage__row { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.bar { height: 10px; background: rgba(255, 255, 255, 0.07); border: 1px solid var(--line-soft); }
.bar__fill {
  height: 100%;
  width: 0;
  background: repeating-linear-gradient(90deg, var(--cyan) 0 8px, #57e6ff 8px 16px);
  box-shadow: 0 0 12px rgba(54, 217, 255, 0.6);
  transition: width 0.5s ease;
}

/* ---------- buttons ---------- */
.btn {
  width: 100%;
  min-height: 50px;
  border: 0;
  font: inherit;
  font-weight: 900;
  font-size: 15px;
  letter-spacing: 0.4px;
  color: #061224;
  cursor: pointer;
  clip-path: polygon(0 6px, 6px 0, calc(100% - 6px) 0, 100% 6px, 100% calc(100% - 6px), calc(100% - 6px) 100%, 6px 100%, 0 calc(100% - 6px));
  transition: transform 0.08s ease, filter 0.15s ease;
}
.btn:active { transform: translateY(2px); filter: brightness(0.92); }
.btn--primary { background: var(--yellow); box-shadow: 0 0 22px rgba(255, 210, 63, 0.35); }
.btn--secondary { background: var(--cyan); box-shadow: 0 0 22px rgba(54, 217, 255, 0.3); }
.btn--pink { background: var(--pink); color: #fff; box-shadow: 0 0 22px rgba(255, 93, 158, 0.35); }
.btn-ghost {
  border: 1px solid var(--line-soft);
  background: transparent;
  color: var(--muted);
  padding: 7px 12px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.topup-note { margin: -2px 0 12px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.topup-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.topup-btn {
  min-height: 68px;
  border: 1px solid var(--line);
  background: rgba(54, 217, 255, 0.08);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  clip-path: polygon(0 5px, 5px 0, calc(100% - 5px) 0, 100% 5px, 100% calc(100% - 5px), calc(100% - 5px) 100%, 5px 100%, 0 calc(100% - 5px));
}
.topup-btn b, .topup-btn span { display: block; }
.topup-btn b { font-size: 15px; color: var(--cyan); }
.topup-btn span { margin-top: 5px; font-size: 12px; color: var(--yellow); font-weight: 800; }
.topup-btn:active { transform: translateY(2px); background: rgba(54, 217, 255, 0.16); }

/* ---------- skills list ---------- */
.skills { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.skills li { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.skills img {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--line-soft);
  image-rendering: pixelated;
  flex: none;
}
.skills .soon { opacity: 0.55; }

/* ---------- kv rows ---------- */
.kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 14px;
}
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv b { text-align: right; word-break: break-word; }

/* ---------- history ---------- */
.history__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.history li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line-soft);
  font-size: 13px;
}
.history .meta b { display: block; font-size: 13px; }
.history .meta small { color: var(--muted); font-size: 11px; }
.history .amt { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amt.plus { color: var(--lime); }
.amt.minus { color: var(--pink); }
.history-empty { color: var(--muted); font-size: 13px; padding: 6px 2px; }

/* ---------- model cards ---------- */
.model-card {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 14px;
  margin-bottom: 12px;
  clip-path: polygon(0 8px, 8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px));
}
.model-card img { width: 76px; height: 76px; border-radius: 12px; border: 1px solid var(--line-soft); image-rendering: pixelated; }
.model-card h3 { margin: 0 0 4px; font-size: 17px; }
.model-card .desc { margin: 0 0 6px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.model-card .how { font-size: 12.5px; color: var(--text); background: rgba(54, 217, 255, 0.08); border: 1px solid var(--line-soft); padding: 7px 9px; margin: 6px 0; word-break: break-word; }
.model-card .price-row { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; color: var(--muted); }
.model-card .price-row b { color: var(--yellow); }
.model-card.locked { opacity: 0.55; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: 1px solid var(--pink);
  color: var(--pink);
}

/* ---------- pay ---------- */
.banner { width: 100%; border: 1px solid var(--line); image-rendering: pixelated; clip-path: polygon(0 8px, 8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px)); }
.plan-card {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 16px;
  display: grid;
  gap: 10px;
  clip-path: polygon(0 8px, 8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px));
}
.plan-card--hot { border-color: var(--yellow); box-shadow: 0 0 26px rgba(255, 210, 63, 0.18); }
.plan-card__head { display: flex; justify-content: space-between; align-items: baseline; }
.plan-card h2 { margin: 0; font-size: 22px; }
.price { color: var(--yellow); font-weight: 900; font-size: 20px; }
.price small { color: var(--muted); font-weight: 400; font-size: 12px; }
.plan-card ul { margin: 0; padding: 0 0 0 18px; color: #cfe3f2; font-size: 13.5px; line-height: 1.8; }

/* ---------- profile ---------- */
.help-text { margin: 0; font-size: 13px; line-height: 1.7; color: #cfe3f2; }
.help-text code { color: var(--cyan); font-size: 12px; }

/* ---------- admin ---------- */
.adm-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 13px; }
.adm-stats .cell { background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line-soft); padding: 9px 11px; }
.adm-stats .cell span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.adm-stats .cell b { font-size: 16px; }
.adm-models { display: grid; gap: 8px; }
.adm-models .toggle-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; background: rgba(255,255,255,0.04); border: 1px solid var(--line-soft); font-size: 14px; }
.toggle {
  min-width: 64px;
  padding: 6px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid var(--lime);
  color: var(--lime);
  background: transparent;
  cursor: pointer;
}
.toggle.off { border-color: var(--red); color: var(--red); }
.search-row { display: flex; gap: 8px; margin-bottom: 10px; }
.input {
  flex: 1;
  min-width: 0;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line-soft);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 9px 11px;
}
.adm-user {
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.03);
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 13px;
}
.adm-user .head { display: flex; justify-content: space-between; margin-bottom: 5px; }
.adm-user .head b { font-size: 14px; }
.adm-user .meta { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.adm-user .actions { display: flex; flex-wrap: wrap; gap: 6px; }
.adm-user .actions button {
  border: 1px solid var(--line-soft);
  background: rgba(54, 217, 255, 0.08);
  color: var(--text);
  font: inherit;
  font-size: 11.5px;
  padding: 6px 9px;
  cursor: pointer;
}
.adm-user .actions button.danger { border-color: rgba(255, 97, 97, 0.5); background: rgba(255, 97, 97, 0.08); }

/* ---------- error ---------- */
.error-img { width: min(78%, 340px); border: 1px solid var(--line); image-rendering: pixelated; }
.error-text { color: var(--muted); font-size: 15px; }

/* ---------- bottom nav ---------- */
.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  justify-content: center;
  gap: 2px;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  background: rgba(4, 10, 24, 0.94);
  border-top: 1px solid var(--line-soft);
  backdrop-filter: blur(16px);
}
.nav__item {
  flex: 1;
  max-width: 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 2px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
}
.nav__icon { font-size: 17px; line-height: 1; filter: grayscale(0.6) opacity(0.75); }
.nav__item.is-active { color: var(--cyan); text-shadow: 0 0 12px rgba(54, 217, 255, 0.7); }
.nav__item.is-active .nav__icon { filter: none; }

@media (max-width: 380px) {
  .panel--status { grid-template-columns: 1fr 1fr 1fr; gap: 4px; }
  .stat__value { font-size: 16px; }
  .adm-stats { grid-template-columns: 1fr; }
  .hero__title { font-size: 28px; }
}
