:root {
  --bg: #0a0b14;
  --bg-alt: #0f1120;
  --card: rgba(255, 255, 255, 0.055);
  --card-border: rgba(255, 255, 255, 0.09);
  --text: #f2f3f8;
  --text-dim: #9497ad;
  --text-faint: #6a6d85;
  --accent: #7c5cff;
  --accent-2: #37e6c1;
  --accent-grad: linear-gradient(135deg, #7c5cff 0%, #5b8cff 55%, #37e6c1 100%);
  --danger: #ff5c7a;
  --ok: #37e6c1;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 11px;
  --shadow-card: 0 8px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

.bg-orbs {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.35;
}
.orb-a {
  width: 340px; height: 340px;
  top: -120px; left: -80px;
  background: #7c5cff;
  animation: float-a 14s ease-in-out infinite;
}
.orb-b {
  width: 300px; height: 300px;
  bottom: -100px; right: -60px;
  background: #37e6c1;
  animation: float-b 16s ease-in-out infinite;
}
@keyframes float-a {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(30px, 40px); }
}
@keyframes float-b {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-25px, -30px); }
}

#app {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 96px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 6px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: var(--accent-grad);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: 15px;
  color: #0a0b14;
}
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: 0.2px; }
.tier-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(124, 92, 255, 0.16);
  border: 1px solid rgba(124, 92, 255, 0.35);
  color: #c9bfff;
}

#views { padding: 14px 16px 8px; }

.hidden { display: none !important; }

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(18px);
}

.hero-card {
  padding: 26px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.ring-wrap { position: relative; width: 132px; height: 132px; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 10;
}
.ring-fill {
  fill: none;
  stroke: url(#none);
  stroke: #7c5cff;
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 327;
  stroke-dashoffset: 327;
  transition: stroke-dashoffset 0.8s cubic-bezier(.4,0,.2,1), stroke 0.4s;
}
.ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.ring-value { font-size: 20px; font-weight: 800; }
.ring-label { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

.hero-meta { text-align: center; }
.hero-meta-row {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 14px; font-weight: 600;
}
.hero-meta-row.muted { color: var(--text-dim); font-weight: 500; font-size: 13px; margin-top: 4px; }

.dot {
  width: 8px; height: 8px; border-radius: 50%;
  box-shadow: 0 0 0 4px transparent;
}
.dot-ok { background: var(--ok); box-shadow: 0 0 0 4px rgba(55, 230, 193, 0.18); }
.dot-warn { background: #ffb24a; box-shadow: 0 0 0 4px rgba(255, 178, 74, 0.18); }
.dot-off { background: var(--text-faint); }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.stat-card {
  padding: 16px;
  text-align: center;
}
.stat-num { font-size: 22px; font-weight: 800; }
.stat-label { font-size: 12px; color: var(--text-dim); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.4px; }

.btn {
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 700;
  padding: 14px 18px;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn-block { width: 100%; margin-top: 10px; }
.btn-primary {
  background: var(--accent-grad);
  color: #0a0b14;
  box-shadow: 0 6px 20px rgba(124, 92, 255, 0.35);
}
.btn-ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--card-border);
}
.btn-sm { padding: 9px 14px; font-size: 13px; }
.btn-danger { background: rgba(255, 92, 122, 0.14); color: #ff8ba1; border: 1px solid rgba(255, 92, 122, 0.3); }
.btn[disabled] { opacity: 0.5; pointer-events: none; }

.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 4px 2px 12px;
}
.section-head h2 { margin: 0; font-size: 19px; font-weight: 800; }

.device-list, .plan-list { display: flex; flex-direction: column; gap: 12px; }

.device-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.device-card-top {
  display: flex; align-items: center; justify-content: space-between;
}
.device-name { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.device-sub { font-size: 12px; color: var(--text-dim); }
.device-usage { font-size: 12px; color: var(--text-dim); }
.device-actions { display: flex; gap: 8px; }
.device-actions .btn { flex: 1; padding: 10px; font-size: 13px; }

.empty-hint { color: var(--text-dim); font-size: 14px; text-align: center; margin-top: 30px; }

.plan-card {
  padding: 18px;
  position: relative;
  overflow: hidden;
}
.plan-card.current { border-color: rgba(124, 92, 255, 0.55); }
.plan-card-top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.plan-name { font-size: 17px; font-weight: 800; }
.plan-price { font-size: 15px; font-weight: 700; color: var(--accent-2); }
.plan-price small { color: var(--text-dim); font-weight: 500; font-size: 12px; }
.plan-features { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-direction: column; gap: 6px; }
.plan-features li { font-size: 13px; color: var(--text-dim); display: flex; gap: 8px; }
.plan-features li::before { content: "✓"; color: var(--accent-2); font-weight: 800; }
.current-badge {
  display: inline-block;
  margin-left: 8px;
  vertical-align: middle;
  font-size: 11px; font-weight: 700; color: var(--accent-2);
  background: rgba(55, 230, 193, 0.12);
  border: 1px solid rgba(55, 230, 193, 0.3);
  padding: 3px 9px; border-radius: 999px;
}

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 5;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  background: rgba(15, 17, 32, 0.85);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--card-border);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}
.tab {
  flex: 1;
  background: none; border: none;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 600;
  padding: 8px 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.tab-icon { font-size: 18px; line-height: 1; }
.tab.active { color: var(--text); background: rgba(124, 92, 255, 0.14); }

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(4, 5, 12, 0.6);
  backdrop-filter: blur(6px);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 20;
}
.modal {
  width: 100%;
  max-width: 480px;
  background: var(--bg-alt);
  border: 1px solid var(--card-border);
  border-radius: 22px 22px 0 0;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  animation: slide-up 0.2s ease;
}
@keyframes slide-up {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal h3 { margin: 0 0 14px; font-size: 17px; }
.modal input {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  padding: 13px 14px;
}
.modal-error { color: var(--danger); font-size: 13px; margin: 8px 0 0; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn { flex: 1; text-align: center; text-decoration: none; }

.qr-wrap {
  display: flex; justify-content: center;
  background: #fff;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
}
.qr-wrap img { width: 220px; height: 220px; }

.muted { color: var(--text-dim); }
.small { font-size: 12px; }
.warn-note {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 178, 74, 0.1);
  border: 1px solid rgba(255, 178, 74, 0.3);
  color: #ffcf8a;
}

.toast {
  position: fixed;
  left: 50%; bottom: 100px;
  transform: translateX(-50%);
  background: #1c1e30;
  border: 1px solid var(--card-border);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  z-index: 30;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
