:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --border: #e6ebf2;
  --border-strong: #d5dde8;
  --text: #0f172a;
  --text-sub: #64748b;
  --text-muted: #94a3b8;
  --primary: #4f46e5;
  --primary-soft: #eef2ff;
  --grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #ec4899 100%);
  --ok-bg: #ecfdf5;
  --ok-text: #047857;
  --ok-border: #a7f3d0;
  --warn-bg: #fffbeb;
  --warn-text: #92400e;
  --warn-border: #fde68a;
  --err-bg: #fef2f2;
  --err-text: #b91c1c;
  --err-border: #fecaca;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 18px 48px rgba(15, 23, 42, 0.16);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font-family: inherit; font-size: inherit; }
button { cursor: pointer; border: none; background: none; padding: 0; color: inherit; }

/* Boot */
.boot-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-sub);
}
.boot-spinner {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Auth Screen */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(circle at 12% 10%, rgba(79,70,229,0.10), transparent 40%),
    radial-gradient(circle at 88% 85%, rgba(236,72,153,0.10), transparent 40%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 410px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
}
.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 22px;
}
.auth-logo {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  object-fit: cover;
  box-shadow: 0 8px 24px rgba(79,70,229,0.22);
  margin-bottom: 10px;
}
.auth-title { font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.auth-sub { font-size: 12px; color: var(--text-sub); margin-top: 3px; }
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--bg);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 18px;
}
.auth-tab {
  padding: 9px 10px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-sub);
  transition: all 0.18s;
}
.auth-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(15,23,42,0.06);
}

/* Form Controls */
.field { margin-bottom: 13px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 5px;
}
.input {
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}
.input-row { display: flex; gap: 8px; }
.input-row .input { flex: 1; min-width: 0; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 6px 18px rgba(79,70,229,0.25);
}
.btn-primary:hover:not(:disabled) { opacity: 0.94; transform: translateY(-1px); }
.btn-dark {
  background: #0f172a;
  color: #fff;
}
.btn-dark:hover:not(:disabled) { background: #1e293b; }
.btn-outline {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
}
.btn-outline:hover:not(:disabled) { background: var(--surface-soft); border-color: #cbd5e1; }
.btn-soft {
  background: var(--primary-soft);
  color: var(--primary);
}
.btn-soft:hover:not(:disabled) { background: #e0e7ff; }
.btn-ghost {
  background: var(--bg);
  color: var(--text-sub);
}
.btn-ghost:hover:not(:disabled) { background: #e9eef6; color: var(--text); }
.btn-danger-soft {
  background: var(--err-bg);
  color: var(--err-text);
}
.btn-lg { padding: 12px 20px; font-size: 14px; border-radius: 13px; }
.btn-block { width: 100%; }

/* Shell Layout */
.shell {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 236px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px 18px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.brand-row img {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  object-fit: cover;
}
.brand-name { font-weight: 800; font-size: 15px; line-height: 1.2; }
.brand-tag { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.nav-list { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-sub);
  transition: all 0.15s;
  text-align: left;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  width: 100%;
  text-align: left;
  transition: border-color 0.15s;
}
.user-pill:hover { border-color: var(--border-strong); }
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 800;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.user-meta { min-width: 0; flex: 1; }
.user-email { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-bal { font-size: 11px; color: var(--text-sub); }

/* Mobile Header & Bottom Tabbar */
.mobile-header { display: none; }
.mobile-nav { display: none; }

/* Main Content */
.main {
  flex: 1;
  min-width: 0;
  padding: 24px 28px 40px;
  max-width: 1040px;
  margin: 0 auto;
  width: 100%;
}
.page-head { margin-bottom: 18px; }
.page-title { font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.page-sub { font-size: 13px; color: var(--text-sub); margin-top: 2px; }

/* Cards & Banners */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card + .card, .section + .section { margin-top: 16px; }
.section { margin-top: 20px; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-title { font-size: 15px; font-weight: 700; }
.section-hint { font-size: 12px; color: var(--text-muted); }

.notice-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 13px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
  font-size: 13px;
  margin-bottom: 16px;
}
.notice-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.notice-badge {
  background: #f59e0b;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  flex-shrink: 0;
}
.notice-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notice-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* Hero Subscription Card */
.hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.status-ok { background: var(--ok-bg); color: var(--ok-text); border: 1px solid var(--ok-border); }
.status-warn { background: var(--warn-bg); color: var(--warn-text); border: 1px solid var(--warn-border); }
.status-err { background: var(--err-bg); color: var(--err-text); border: 1px solid var(--err-border); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.hero-plan { font-size: 22px; font-weight: 800; margin-top: 8px; letter-spacing: -0.01em; }
.hero-meta { font-size: 13px; color: var(--text-sub); margin-top: 4px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.progress-box {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.progress-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 8px;
}
.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #edf1f7;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--grad);
  transition: width 0.35s ease;
}

/* Grids */
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

.step-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow);
}
.step-top { display: flex; align-items: center; justify-content: space-between; }
.step-num {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 7px;
  background: var(--primary-soft);
  color: var(--primary);
}
.step-title { font-size: 14px; font-weight: 700; margin-top: 8px; }
.step-desc { font-size: 12px; color: var(--text-sub); margin-top: 4px; }

/* Status Footer Bar */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 13px 16px;
  font-size: 13px;
}
.link-group { display: flex; align-items: center; gap: 12px; color: var(--text-sub); font-size: 12px; flex-wrap: wrap; }
.link-group button:hover { color: var(--primary); }

/* Plan Cards */
.plan-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  position: relative;
  box-shadow: var(--shadow);
}
.plan-card.featured { border-color: var(--primary); box-shadow: 0 10px 28px rgba(79,70,229,0.12); }
.plan-badge {
  position: absolute;
  top: -11px;
  right: 16px;
  background: var(--grad);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}
.plan-name { font-size: 16px; font-weight: 800; }
.plan-price { font-size: 26px; font-weight: 800; color: var(--text); margin-top: 6px; }
.plan-price small { font-size: 12px; font-weight: 500; color: var(--text-sub); }
.plan-desc { font-size: 12px; color: var(--text-sub); white-space: pre-line; margin-top: 8px; }
.plan-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 7px;
  background: var(--bg);
  color: var(--text-sub);
  font-weight: 600;
}

/* Download Card */
.dl-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow);
}
.dl-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.dl-ico {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

/* Lists / Tables */
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; padding-bottom: 0; }
.list-item:first-child { padding-top: 0; }

/* Period & Payment Pills */
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.choice-btn {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  text-align: left;
  transition: all 0.15s;
}
.choice-btn.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.choice-title { font-size: 13px; font-weight: 700; }
.choice-sub { font-size: 12px; color: var(--text-sub); margin-top: 2px; }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}
.modal-box {
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow-lg);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.modal-title { font-size: 16px; font-weight: 800; }
.modal-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--text-sub);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 26px rgba(15,23,42,0.28);
  z-index: 2000;
  max-width: 90vw;
  text-align: center;
}

/* Responsive Mobile */
@media (max-width: 820px) {
  .sidebar { display: none; }
  .shell { flex-direction: column; padding-bottom: 70px; }
  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
  }
  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    z-index: 60;
  }
  .mnav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 11px;
    color: var(--text-sub);
    padding: 4px 0;
  }
  .mnav-btn.active { color: var(--primary); font-weight: 700; }
  .mnav-ico { font-size: 18px; line-height: 1.1; }
  .main { padding: 14px 14px 28px; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .hero-actions { width: 100%; }
  .hero-actions .btn { flex: 1; }
  .toast { bottom: 84px; }
}
