/* PanelSwap — Dark Theme */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0f;
  --bg2: #12121a;
  --bg3: #1a1a26;
  --border: #1e293b;
  --border2: #2d3748;
  --text: #e2e8f0;
  --text2: #94a3b8;
  --text3: #64748b;
  --primary: #6366f1;
  --primary-h: #4f46e5;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 15px; line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
button { cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* Loading screen */
.loading-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; gap: 16px; color: var(--text2); }
.loading-logo { width: 80px; height: 80px; border-radius: 16px; overflow: hidden; margin-bottom: 8px; }
.loading-logo img { width: 100%; height: 100%; object-fit: cover; }
.spinner { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* App layout */
#app { min-height: 100vh; }
.app-shell { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 240px; min-height: 100vh; background: var(--bg2);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; z-index: 100; transition: transform 0.3s;
}
.sidebar-logo { padding: 16px; border-bottom: 1px solid var(--border); }
.sidebar-logo a { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 18px; }
.sidebar-logo a:hover { text-decoration: none; }
.sidebar-logo-img { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.nav-section { margin-bottom: 8px; }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text3); padding: 8px 10px 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--text2); font-size: 14px; cursor: pointer; user-select: none; transition: all 0.15s; }
.nav-item:hover { background: var(--bg3); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item .nav-icon { font-size: 16px; flex-shrink: 0; }
.sidebar-footer { padding: 12px 8px; border-top: 1px solid var(--border); }
.user-card { display: flex; align-items: center; gap: 10px; padding: 10px; background: var(--bg3); border-radius: var(--radius-sm); }
.user-avatar { width: 36px; height: 36px; background: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; color: #fff; flex-shrink: 0; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-balance { font-size: 12px; color: var(--success); font-weight: 500; }

/* Main content */
.main-content { flex: 1; margin-left: 240px; display: flex; flex-direction: column; min-height: 100vh; }
.topbar { height: 56px; background: var(--bg2); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 50; }
.topbar-title { font-size: 16px; font-weight: 600; color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.page-content { padding: 24px; flex: 1; }

/* Mobile sidebar */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 99; }
.menu-btn { display: none; background: none; border: none; color: var(--text2); font-size: 20px; padding: 4px; }
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0; }
  .menu-btn { display: block; }
  .page-content { padding: 16px; }
}

/* Auth pages */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 36px; }
.auth-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.auth-logo span { font-size: 22px; font-weight: 700; color: var(--text); }
.auth-logo-img { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; flex-shrink: 0; }
.auth-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.auth-sub { color: var(--text2); font-size: 14px; margin-bottom: 24px; }

/* Cards */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card-sm { padding: 14px; }

/* Stat cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat-label { font-size: 12px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--text); }
.stat-sub { font-size: 12px; color: var(--text3); margin-top: 4px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text2); margin-bottom: 6px; }
.form-input { width: 100%; padding: 10px 12px; background: var(--bg3); border: 1px solid var(--border2); border-radius: var(--radius-sm); color: var(--text); font-size: 14px; outline: none; transition: border-color 0.15s; }
.form-input:focus { border-color: var(--primary); }
.form-input::placeholder { color: var(--text3); }
select.form-input { cursor: pointer; }
textarea.form-input { resize: vertical; min-height: 80px; }
.form-hint { font-size: 12px; color: var(--text3); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; border: none; transition: all 0.15s; cursor: pointer; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #000; }
.btn-outline { background: transparent; color: var(--text2); border: 1px solid var(--border2); }
.btn-outline:hover { background: var(--bg3); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text2); }
.btn-ghost:hover { color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; padding: 10px 12px; background: var(--bg3); color: var(--text2); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; border-bottom: 1px solid var(--border); }
td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg3); }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.badge-green { background: rgba(16,185,129,0.15); color: #10b981; }
.badge-red { background: rgba(239,68,68,0.15); color: #ef4444; }
.badge-yellow { background: rgba(245,158,11,0.15); color: #f59e0b; }
.badge-blue { background: rgba(59,130,246,0.15); color: #3b82f6; }
.badge-purple { background: rgba(99,102,241,0.15); color: #6366f1; }
.badge-gray { background: rgba(100,116,139,0.15); color: #64748b; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; }
.alert-error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.alert-success { background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.3); color: #6ee7b7; }
.alert-info { background: rgba(59,130,246,0.1); border: 1px solid rgba(59,130,246,0.3); color: #93c5fd; }
.alert-warning { background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.3); color: #fcd34d; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; animation: fadeIn 0.15s; }
.modal { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text3); font-size: 20px; cursor: pointer; line-height: 1; }
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Toast */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 16px; font-size: 14px; box-shadow: var(--shadow); min-width: 260px; max-width: 380px; animation: slideIn 0.2s; display: flex; gap: 10px; align-items: flex-start; }
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-info { border-left: 3px solid var(--info); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Page header */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 700; }
.page-header p { color: var(--text2); font-size: 14px; margin-top: 4px; }

/* Section title */
.section-title { font-size: 14px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 12px; }

/* Tab nav */
.tab-nav { display: flex; gap: 4px; background: var(--bg3); padding: 4px; border-radius: var(--radius-sm); margin-bottom: 20px; }
.tab-btn { flex: 1; padding: 8px 12px; border-radius: 6px; border: none; background: none; color: var(--text2); font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.15s; }
.tab-btn.active { background: var(--primary); color: #fff; }
.tab-btn:hover:not(.active) { color: var(--text); background: var(--border); }

/* Plan cards */
.plans-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.plan-card { background: var(--bg3); border: 2px solid var(--border); border-radius: var(--radius); padding: 24px; position: relative; transition: border-color 0.2s; }
.plan-card.featured { border-color: var(--primary); }
.plan-name { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.plan-price { font-size: 28px; font-weight: 800; color: var(--primary); margin: 12px 0; }
.plan-price span { font-size: 14px; font-weight: 400; color: var(--text2); }
.plan-feat { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text2); margin-bottom: 6px; }

/* Mission card */
.mission-card { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 12px; }
.mission-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.mission-title { font-weight: 600; }
.mission-reward { color: var(--success); font-weight: 700; }
.mission-progress { background: var(--border); border-radius: 4px; height: 6px; margin: 8px 0; overflow: hidden; }
.mission-progress-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width 0.4s; }

/* Service card */
.services-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.service-card { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; cursor: pointer; transition: border-color 0.15s; }
.service-card:hover, .service-card.selected { border-color: var(--primary); }
.service-name { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.service-meta { display: flex; gap: 12px; font-size: 12px; color: var(--text2); }
.service-price { font-size: 16px; font-weight: 700; color: var(--primary); margin-top: 8px; }

/* Pagination */
.pagination { display: flex; gap: 6px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.page-btn { padding: 6px 12px; border: 1px solid var(--border2); border-radius: var(--radius-sm); background: var(--bg3); color: var(--text2); font-size: 13px; cursor: pointer; }
.page-btn.active, .page-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Copy input */
.copy-wrap { display: flex; gap: 8px; }
.copy-wrap .form-input { flex: 1; font-family: monospace; font-size: 13px; }

/* VIP badge */
.vip-badge { display: inline-flex; align-items: center; gap: 4px; background: linear-gradient(135deg, #f59e0b, #d97706); color: #000; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; }

/* Toolbar */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar-right { margin-left: auto; }

/* Course card */
.courses-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.course-card { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.course-thumb { width: 100%; height: 140px; object-fit: cover; background: var(--border); display: block; }
.course-thumb-placeholder { width: 100%; height: 140px; background: linear-gradient(135deg, var(--bg2), var(--bg3)); display: flex; align-items: center; justify-content: center; font-size: 32px; }
.course-body { padding: 14px; }
.course-title { font-weight: 600; margin-bottom: 6px; }
.course-desc { font-size: 13px; color: var(--text2); margin-bottom: 12px; }

/* Tutorial items */
.tutorial-item { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 10px; }
.tutorial-item-title { font-weight: 600; margin-bottom: 6px; }
.tutorial-item-desc { font-size: 13px; color: var(--text2); }

/* Code block */
pre, code { font-family: 'Courier New', monospace; font-size: 13px; }
pre { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; overflow-x: auto; color: var(--text2); }

/* Toggle */
.toggle { position: relative; display: inline-block; width: 40px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: var(--border2); border-radius: 22px; transition: 0.2s; }
.toggle-slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: 0.2s; }
input:checked + .toggle-slider { background: var(--primary); }
input:checked + .toggle-slider:before { transform: translateX(18px); }

/* Flex utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-muted { color: var(--text2); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary); }
.text-warning { color: var(--warning); }
.font-bold { font-weight: 700; }
.font-mono { font-family: monospace; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-full { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .grid-2 { grid-template-columns: 1fr; } }

/* Empty state */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text2); }
.empty-state-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.empty-state p { font-size: 13px; }

/* Search input */
.search-wrap { position: relative; }
.search-wrap .form-input { padding-left: 36px; }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text3); font-size: 16px; }

/* Divider */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
