:root {
  --bg: #060a13;
  --bg-2: #0b1220;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.075);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #e8eef8;
  --muted: #8b98ae;
  --faint: #5b667a;
  --accent: #2dd4bf;
  --accent-2: #22d3ee;
  --accent-ink: #032b28;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --off: #94a3b8;
  --radius: 18px;
  --radius-sm: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  min-height: 100vh;
  overflow-x: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }

.bg-glow {
  position: fixed; inset: -20% -30% auto -30%; height: 420px; z-index: 0; pointer-events: none;
  background:
    radial-gradient(40% 60% at 25% 30%, rgba(45, 212, 191, 0.20), transparent 70%),
    radial-gradient(35% 50% at 80% 10%, rgba(34, 211, 238, 0.14), transparent 70%);
  filter: blur(10px);
}

.view {
  position: relative; z-index: 1;
  padding: 16px 16px calc(96px + var(--safe-b));
  max-width: 560px; margin: 0 auto;
}

/* ---------- header ---------- */
.top { display: flex; align-items: center; gap: 12px; margin: 4px 0 18px; }
.logo {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-ink); font-weight: 800; font-size: 18px;
  box-shadow: 0 6px 20px rgba(45, 212, 191, 0.35);
}
.top h1 { font-size: 17px; margin: 0; font-weight: 800; letter-spacing: 0.2px; }
.top .sub { color: var(--muted); font-size: 12px; }
.chip-id {
  margin-left: auto; font-size: 12px; color: var(--muted);
  padding: 6px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border);
}

/* ---------- cards ---------- */
.glass {
  background: linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.03));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.balance { padding: 18px; position: relative; overflow: hidden; }
.balance::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%;
  background: radial-gradient(circle, rgba(45,212,191,0.28), transparent 65%);
}
.balance .lbl { color: var(--muted); font-size: 13px; }
.balance .amt { font-size: 36px; font-weight: 800; letter-spacing: -0.5px; margin: 2px 0 14px; }
.balance .amt small { font-size: 18px; color: var(--muted); font-weight: 700; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat { background: rgba(0,0,0,0.18); border: 1px solid var(--border); border-radius: 12px; padding: 10px 8px; }
.stat b { display: block; font-size: 18px; font-weight: 800; }
.stat span { color: var(--muted); font-size: 11px; }

.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0 22px; }
.qa {
  padding: 14px 8px; border-radius: 16px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); font-weight: 700; font-size: 13px;
  transition: transform .12s ease, background .2s;
}
.qa:active { transform: scale(0.97); background: var(--surface-2); }
.qa .ic { display: block; font-size: 20px; margin-bottom: 4px; }
.qa.primary { background: linear-gradient(135deg, rgba(45,212,191,0.22), rgba(34,211,238,0.12)); border-color: rgba(45,212,191,0.35); }

.section-h { display: flex; align-items: center; justify-content: space-between; margin: 6px 2px 10px; }
.section-h h2 { font-size: 15px; margin: 0; font-weight: 800; }
.section-h a, .link-btn { color: var(--accent); font-size: 13px; font-weight: 700; text-decoration: none; }

/* ---------- client rows ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  text-align: left; width: 100%;
  transition: background .2s, transform .12s;
}
.row:active { transform: scale(0.99); background: var(--surface-2); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot.ACTIVE { background: var(--ok); box-shadow: 0 0 10px rgba(52,211,153,0.6); }
.dot.EXPIRED { background: var(--danger); }
.dot.LIMITED { background: var(--warn); }
.dot.DISABLED { background: var(--off); }
.row .main { flex: 1; min-width: 0; }
.row .name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .right { text-align: right; font-size: 12px; color: var(--muted); flex: none; }
.row .right b { display: block; color: var(--text); font-size: 13px; }
.tag { font-size: 10px; font-weight: 800; padding: 2px 6px; border-radius: 6px; margin-left: 6px; vertical-align: 2px; }
.tag.vip { background: rgba(251,191,36,0.15); color: var(--warn); }
.tag.gb { background: rgba(34,211,238,0.14); color: var(--accent-2); }
.bar { height: 4px; border-radius: 4px; background: rgba(255,255,255,0.08); margin-top: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 4px; }
.bar i.hot { background: linear-gradient(90deg, var(--warn), var(--danger)); }

.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty .big { font-size: 34px; margin-bottom: 8px; }

/* ---------- search & filters ---------- */
.search {
  width: 100%; padding: 13px 14px 13px 40px; border-radius: 14px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%238b98ae' stroke-width='2' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 13px center;
  border: 1px solid var(--border); outline: none;
}
.search:focus { border-color: rgba(45,212,191,0.5); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 14px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 8px 13px; border-radius: 999px; font-size: 13px; font-weight: 700;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
}
.chip.on { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.chip .n { opacity: 0.7; margin-left: 4px; }

/* ---------- segmented ---------- */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); margin-bottom: 14px; }
.seg button { padding: 10px; border-radius: 10px; font-weight: 700; color: var(--muted); }
.seg button.on { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong); }

/* ---------- plans ---------- */
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.plan {
  padding: 14px; border-radius: 16px; text-align: left; position: relative;
  background: var(--surface); border: 1px solid var(--border);
  transition: border-color .2s, transform .12s;
}
.plan:active { transform: scale(0.98); }
.plan.on { border-color: var(--accent); background: linear-gradient(180deg, rgba(45,212,191,0.12), rgba(45,212,191,0.03)); }
.plan .pe { font-size: 22px; }
.plan .pn { font-weight: 800; margin-top: 6px; }
.plan .pd { color: var(--muted); font-size: 12px; margin-top: 2px; }
.plan .pp { font-size: 20px; font-weight: 800; margin-top: 10px; }
.plan .pp small { font-size: 12px; color: var(--muted); font-weight: 600; }
.plan.vip .pp { color: var(--warn); }

.field { margin: 16px 0 8px; }
.field label { display: block; color: var(--muted); font-size: 13px; margin: 0 2px 6px; }
.input {
  width: 100%; padding: 14px; border-radius: 14px; outline: none;
  background: var(--surface); border: 1px solid var(--border);
}
.input:focus { border-color: rgba(45,212,191,0.5); }
.hint { color: var(--faint); font-size: 12px; margin: 6px 2px 0; }

.btn {
  width: 100%; padding: 15px; border-radius: 16px; font-weight: 800; font-size: 15px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink);
  box-shadow: 0 8px 24px rgba(45,212,191,0.25);
  transition: transform .12s, opacity .2s;
}
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.45; box-shadow: none; }
.btn.ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: none; }
.btn.danger { background: rgba(248,113,113,0.12); color: var(--danger); border: 1px solid rgba(248,113,113,0.3); box-shadow: none; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.summary { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin: 14px 2px 10px; }
.summary b { color: var(--text); }
.summary .low { color: var(--danger); }

/* ---------- sheet ---------- */
.sheet-back { position: fixed; inset: 0; background: rgba(2,6,14,0.6); z-index: 40; opacity: 0; transition: opacity .2s; }
.sheet-back.show { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 92vh; overflow-y: auto;
  background: var(--bg-2); border-top: 1px solid var(--border-strong);
  border-radius: 24px 24px 0 0; padding: 10px 16px calc(20px + var(--safe-b));
  transform: translateY(100%); transition: transform .26s cubic-bezier(.2,.8,.2,1);
  max-width: 560px; margin: 0 auto;
}
.sheet.show { transform: translateY(0); }
.grab { width: 40px; height: 4px; border-radius: 4px; background: var(--border-strong); margin: 0 auto 14px; }
.sheet h3 { margin: 0; font-size: 20px; font-weight: 800; word-break: break-all; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.pill.ACTIVE { background: rgba(52,211,153,0.14); color: var(--ok); }
.pill.EXPIRED { background: rgba(248,113,113,0.14); color: var(--danger); }
.pill.LIMITED { background: rgba(251,191,36,0.14); color: var(--warn); }
.pill.DISABLED { background: rgba(148,163,184,0.16); color: var(--off); }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
.kv div { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.kv span { display: block; color: var(--muted); font-size: 11px; }
.kv b { font-size: 14px; word-break: break-word; }
.linkbox {
  display: flex; gap: 8px; align-items: center; padding: 10px 10px 10px 12px; border-radius: 14px;
  background: rgba(0,0,0,0.25); border: 1px dashed var(--border-strong); margin: 6px 0 12px;
}
.linkbox code { flex: 1; min-width: 0; font-size: 12px; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { padding: 8px 12px; border-radius: 10px; background: var(--surface-2); font-weight: 700; font-size: 13px; flex: none; }
.qr { display: flex; justify-content: center; margin: 4px 0 14px; }
.qr img { width: 210px; height: 210px; border-radius: 16px; background: #fff; padding: 10px; }
.grid-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 14px; }
.ga { padding: 12px 6px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); font-size: 12px; font-weight: 700; text-align: center; }
.ga .ic { display: block; font-size: 18px; margin-bottom: 4px; }
.ga.on { border-color: rgba(45,212,191,0.45); color: var(--accent); }
.ga:active { background: var(--surface-2); }
.devices { list-style: none; padding: 0; margin: 0 0 12px; }
.devices li { padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); margin-bottom: 6px; font-size: 13px; }
.devices li span { color: var(--muted); }
.note { color: var(--muted); font-size: 13px; padding: 10px 12px; border-radius: 12px; background: var(--surface); margin: 0 0 12px; white-space: pre-wrap; }

/* ---------- result ---------- */
.success { text-align: center; padding: 6px 0 10px; }
.success .check {
  width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 10px; display: grid; place-items: center; font-size: 30px;
  background: rgba(52,211,153,0.14); color: var(--ok); box-shadow: 0 0 0 8px rgba(52,211,153,0.06);
}

/* ---------- VIP ---------- */
.vip-hero { padding: 18px; margin-bottom: 14px; background: linear-gradient(135deg, rgba(251,191,36,0.14), rgba(45,212,191,0.06)); }
.vip-hero h2 { margin: 0 0 4px; font-size: 20px; font-weight: 800; }
.vip-hero p { margin: 0; color: var(--muted); font-size: 13px; }
.test-card { display: flex; align-items: center; gap: 12px; padding: 14px; margin-bottom: 16px; }
.test-card .ic { font-size: 26px; }
.test-card .main { flex: 1; }
.test-card b { display: block; }
.test-card span { color: var(--muted); font-size: 12px; }
.test-card .btn { width: auto; padding: 10px 14px; font-size: 13px; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 8px 10px calc(8px + var(--safe-b));
  background: rgba(6,10,19,0.86); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--border);
  max-width: 560px; margin: 0 auto;
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; color: var(--faint); font-weight: 700; font-size: 11px; }
.tab .ti { font-size: 20px; line-height: 1.1; }
.tab.on { color: var(--accent); }
.tab-new .plus {
  width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; font-size: 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink);
}

/* ---------- toast & misc ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(92px + var(--safe-b)); transform: translateX(-50%) translateY(20px);
  background: #111a2b; border: 1px solid var(--border-strong); padding: 10px 16px; border-radius: 12px;
  font-size: 13px; font-weight: 700; z-index: 60; opacity: 0; pointer-events: none; transition: all .22s; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: rgba(248,113,113,0.5); color: #fecaca; }
.skeleton { height: 62px; border-radius: 14px; background: linear-gradient(90deg, var(--surface), var(--surface-2), var(--surface)); background-size: 200% 100%; animation: sk 1.2s infinite; margin-bottom: 8px; }
@keyframes sk { to { background-position: -200% 0; } }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: rot .7s linear infinite; vertical-align: -3px; }
@keyframes rot { to { transform: rotate(360deg); } }
.warn-banner { padding: 10px 12px; border-radius: 12px; background: rgba(251,191,36,0.1); color: var(--warn); font-size: 13px; margin-bottom: 12px; }

@media (max-width: 360px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .plans { grid-template-columns: 1fr; }
}
