/* ===== CSS Variables ===== */
:root {
  --bg: #070711;
  --bg2: #0d0f1e;
  --bg3: #13162b;
  --bg4: #1a1d35;
  --border: #1e2240;
  --border2: #2d3260;
  --primary: #6366f1;
  --primary2: #818cf8;
  --primary-glow: rgba(99, 102, 241, 0.2);
  --accent: #ec4899;
  --accent2: #f472b6;
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.1);
  --warning: #f59e0b;
  --danger: #ef4444;
  --text: #e2e8f0;
  --dim: #8892b0;
  --muted: #4a5280;
  --radius: 14px;
}

/* ===== Reset ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(ellipse 60% 30% at 50% 0%, rgba(99, 102, 241, 0.06) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ===== Background Grid ===== */
.bg-grid {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: linear-gradient(rgba(99, 102, 241, 0.03) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(99, 102, 241, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: 0;
}

/* ===== Topbar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(7, 7, 17, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-left { display: flex; align-items: center; gap: 24px; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand svg { width: 36px; height: 36px; }

.brand span {
  font-size: 16px;
  font-weight: 800;
  background: linear-gradient(135deg, #fff, #c4b5fd);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-links { display: flex; gap: 4px; }

.nav-links a {
  padding: 8px 16px;
  border-radius: 8px;
  color: var(--dim);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.nav-links a:hover { color: var(--text); background: var(--bg3); }
.nav-links a.active { color: var(--primary2); background: var(--primary-glow); }

.topbar-right { display: flex; align-items: center; gap: 16px; }

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
}

.user-badge .avatar {
  width: 24px; height: 24px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  color: white;
}

.user-badge .email { color: var(--dim); }

.btn-logout {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--dim);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover { border-color: var(--danger); color: var(--danger); }

/* ===== Main ===== */
.container { max-width: 1100px; margin: 0 auto; padding: 32px 24px; position: relative; z-index: 1; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}

.page-title { font-size: 22px; font-weight: 700; }
.page-title span { font-size: 13px; color: var(--dim); font-weight: 400; margin-left: 12px; }
.page-subtitle { font-size: 13px; color: var(--dim); }

/* ===== Cards ===== */
.card {
  background: rgba(13, 15, 30, 0.8);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color 0.2s;
}

.card:hover { border-color: var(--border2); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--dim);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title::before {
  content: '';
  width: 4px;
  height: 14px;
  background: linear-gradient(to bottom, var(--primary), var(--accent));
  border-radius: 2px;
}

/* ===== Subscription Status ===== */
.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 28px;
}

@media (max-width: 640px) {
  .status-grid { grid-template-columns: 1fr; }
}

.status-card {
  background: rgba(13, 15, 30, 0.8);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}

.status-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 600; margin-bottom: 10px; }

.status-value { font-size: 28px; font-weight: 800; margin-bottom: 4px; }
.status-value.active { color: var(--success); }
.status-value.inactive { color: var(--danger); }
.status-value.warning { color: var(--warning); }
.status-value.primary { color: var(--primary2); }

.status-sub { font-size: 12px; color: var(--dim); }

.status-active-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--success-bg);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--success);
}

.status-active-badge::before {
  content: '';
  width: 8px; height: 8px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

.status-expired-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--danger);
}

/* ===== Keys ===== */
.keys-section { margin-bottom: 28px; }

.key-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

@media (max-width: 640px) {
  .key-row { grid-template-columns: 1fr; }
}

.key-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}

.key-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
}

.key-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: var(--text);
  word-break: break-all;
  background: var(--bg);
  border-radius: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.key-empty { color: var(--muted); }

.key-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.key-input {
  flex: 1;
  padding: 10px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.key-input:focus { border-color: var(--border2); }
.key-input::placeholder { color: var(--muted); }

.btn-copy {
  padding: 6px 14px;
  background: var(--primary-glow);
  border: 1px solid rgba(99,102,241,0.3);
  border-radius: 8px;
  color: var(--primary2);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-copy:hover { background: rgba(99,102,241,0.3); }

.btn-copy.copied {
  background: var(--success-bg);
  border-color: rgba(34,197,94,0.3);
  color: var(--success);
}

.btn-save-key {
  padding: 6px 16px;
  background: var(--primary);
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-save-key:hover { background: var(--primary2); }
.btn-save-key:disabled { opacity: 0.6; cursor: not-allowed; }

/* ===== Buy Button ===== */
.btn-buy {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  border: none;
  border-radius: 10px;
  color: white;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-buy:hover { box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4); }

.btn-buy.alipay { background: linear-gradient(135deg, #1677ff, #0958d9); }
.btn-buy.alipay:hover { box-shadow: 0 6px 20px rgba(22, 119, 255, 0.4); }

/* ===== Orders ===== */
.orders-section { margin-bottom: 28px; }

.order-table { width: 100%; border-collapse: collapse; }
.order-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.order-table td {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--dim);
  border-bottom: 1px solid rgba(30, 34, 64, 0.5);
}

.order-table tr:last-child td { border-bottom: none; }
.order-table tr:hover td { background: var(--bg3); }

.order-status {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.order-status.paid { background: var(--success-bg); color: var(--success); }
.order-status.pending { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.order-status.refunded { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

/* ===== Loading ===== */
.loading-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(7, 7, 17, 0.8);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(8px);
}

.loading-box { text-align: center; }

.loading-spinner {
  width: 48px; height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Alert ===== */
.alert {
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 20px;
  display: none;
  align-items: center;
  gap: 12px;
}

.alert.success { background: var(--success-bg); border: 1px solid rgba(34,197,94,0.3); color: #86efac; }
.alert.error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.alert.info { background: rgba(99,102,241,0.1); border: 1px solid rgba(99,102,241,0.3); color: #a5b4fc; }

.alert-close {
  margin-left: auto;
  background: none;
  border: none;
  color: currentColor;
  cursor: pointer;
  opacity: 0.7;
  font-size: 18px;
}

.alert-close:hover { opacity: 1; }

.no-data { text-align: center; padding: 32px; color: var(--muted); font-size: 14px; }

/* ===== Payment Modal ===== */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  display: none; align-items: center; justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(8px);
}

.modal-overlay.show { display: flex; }

.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  max-width: 400px;
  width: 90%;
  text-align: center;
}

.modal h3 { font-size: 18px; margin-bottom: 8px; }
.modal p { color: var(--dim); font-size: 14px; margin-bottom: 24px; }

.modal .price { font-size: 36px; font-weight: 800; color: var(--primary2); margin-bottom: 20px; }

.modal .btn-alipay {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #1677ff, #0958d9);
  border: none;
  border-radius: 10px;
  color: white;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  margin-bottom: 12px;
}

.modal .btn-cancel {
  width: 100%;
  padding: 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--dim);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}

.modal .btn-cancel:hover { border-color: var(--border2); color: var(--text); }

.payment-waiting { padding: 24px; text-align: center; }

.payment-waiting .spinner-large {
  width: 48px; height: 48px;
  border: 3px solid var(--border);
  border-top-color: #1677ff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

.payment-waiting h3 { font-size: 18px; margin-bottom: 8px; }
.payment-waiting p { color: var(--dim); font-size: 14px; margin-bottom: 24px; }

.order-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--muted);
  background: var(--bg);
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 20px;
  word-break: break-all;
}

/* ===== Tab System ===== */
.section-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 5px;
  margin-bottom: 28px;
}

.section-tab {
  flex: 1;
  padding: 9px 16px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--dim);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.section-tab:hover { color: var(--text); }
.section-tab.active {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== Model Tabs (API System) ===== */
.model-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.model-tab {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--dim);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  white-space: nowrap;
}

.model-tab:hover { color: var(--text); border-color: var(--border2); background: var(--bg4); }
.model-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }

/* ===== Model Grid (API System) ===== */
.model-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .model-grid { grid-template-columns: 1fr; } }

/* ===== Announcement Styles ===== */
#announcementContainer { position: fixed; top: 0; left: 0; right: 0; z-index: 9999; }

.ann-banner {
  position: relative;
  background: rgba(99,102,241,.12);
  border-bottom: 1px solid rgba(99,102,241,.3);
  padding: 14px 24px;
  text-align: center;
  font-size: 14px;
  color: #c4b5fd;
  line-height: 1.6;
}

.ann-banner .ann-close {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: rgba(196,181,253,.5); cursor: pointer;
  font-size: 20px; padding: 4px; transition: color .2s;
}

.ann-banner .ann-close:hover { color: #c4b5fd; }

.ann-toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  background: rgba(13,15,30,.95); backdrop-filter: blur(12px);
  border: 1px solid rgba(99,102,241,.3);
  border-radius: 14px; padding: 18px 22px;
  max-width: 340px; width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  animation: toastIn .3s ease;
}

.ann-toast .ann-toast-title { font-size: 13px; font-weight: 700; color: #818cf8; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.ann-toast .ann-toast-body { font-size: 13px; color: #8892b0; line-height: 1.6; white-space: pre-wrap; }
.ann-toast .ann-close {
  position: absolute; top: 12px; right: 14px;
  background: none; border: none; color: #4a5280; cursor: pointer;
  font-size: 18px; transition: color .2s;
}
.ann-toast .ann-close:hover { color: #8892b0; }
.ann-toast .ann-progress {
  height: 3px; background: rgba(99,102,241,.2); border-radius: 2px; margin-top: 14px; overflow: hidden;
}
.ann-toast .ann-progress-bar {
  height: 100%; background: var(--primary); border-radius: 2px;
  animation: annProgress 6s linear forwards;
}

.ann-modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.7); z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px);
  animation: fadeIn .2s ease;
}

.ann-modal {
  background: var(--bg2); border: 1px solid rgba(99,102,241,.3);
  border-radius: 20px; padding: 36px;
  max-width: 480px; width: 90%; text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
  animation: modalIn .3s ease;
}

.ann-modal .ann-icon { font-size: 48px; margin-bottom: 16px; }
.ann-modal .ann-title { font-size: 20px; font-weight: 800; color: var(--text); margin-bottom: 16px; }
.ann-modal .ann-body { font-size: 14px; color: var(--dim); line-height: 1.7; white-space: pre-wrap; margin-bottom: 24px; }
.ann-modal .ann-btn {
  padding: 10px 28px; background: linear-gradient(135deg, var(--primary), #7c3aed);
  border: none; border-radius: 10px; color: white;
  font-size: 14px; font-weight: 700; cursor: pointer; font-family: inherit;
  transition: all .2s;
}
.ann-modal .ann-btn:hover { box-shadow: 0 6px 20px rgba(99,102,241,.4); }

.ann-marquee {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 9999;
  background: rgba(99,102,241,.12);
  border-top: 1px solid rgba(99,102,241,.3);
  overflow: hidden; height: 42px; display: flex; align-items: center;
}

.ann-marquee-inner { white-space: nowrap; animation: marqueeScroll 20s linear infinite; font-size: 13px; color: #818cf8; padding-left: 100%; }
.ann-marquee-inner:hover { animation-play-state: paused; }
.ann-marquee .ann-close {
  position: absolute; right: 12px;
  background: none; border: none; color: rgba(129,140,248,.5); cursor: pointer;
  font-size: 16px; z-index: 1;
}

.ann-topbar {
  position: fixed; top: 64px; left: 0; right: 0; z-index: 9998;
  background: rgba(99,102,241,.12);
  border-bottom: 1px solid rgba(99,102,241,.3);
  padding: 10px 24px; text-align: center;
  font-size: 13px; color: #c4b5fd; line-height: 1.6;
  animation: slideDown .3s ease;
}

.ann-topbar .ann-close {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: rgba(196,181,253,.5); cursor: pointer;
  font-size: 18px; padding: 4px;
}

.ann-sidebar {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  background: rgba(13,15,30,.95); backdrop-filter: blur(12px);
  border: 1px solid rgba(99,102,241,.3);
  border-radius: 16px; padding: 20px;
  max-width: 280px; width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  animation: fadeInRight .3s ease;
}

.ann-sidebar .ann-title { font-size: 13px; font-weight: 700; color: #818cf8; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.ann-sidebar .ann-body { font-size: 13px; color: #8892b0; line-height: 1.6; white-space: pre-wrap; }
.ann-sidebar .ann-close {
  position: absolute; top: 12px; right: 14px;
  background: none; border: none; color: #4a5280; cursor: pointer;
  font-size: 18px; transition: color .2s;
}
.ann-sidebar .ann-close:hover { color: #8892b0; }

/* ===== Animations ===== */
@keyframes toastIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: scale(1); } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInRight { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes annProgress { from { width: 100%; } to { width: 0%; } }
@keyframes marqueeScroll { 0% { transform: translateX(0); } 100% { transform: translateX(-200%); } }
