*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0f;
  --bg2: #111118;
  --bg3: #17171f;
  --bg4: #1e1e28;
  --border: #2a2a38;
  --border2: #333345;
  --text: #e8e8f0;
  --text2: #a0a0b8;
  --text3: #6a6a88;
  --primary: #5b5ef4;
  --primary2: #4a4de8;
  --primary-glow: rgba(91,94,244,0.25);
  --green: #22c55e;
  --green-bg: rgba(34,197,94,0.12);
  --blue: #3b82f6;
  --blue-bg: rgba(59,130,246,0.12);
  --orange: #f59e0b;
  --orange-bg: rgba(245,158,11,0.12);
  --purple: #a855f7;
  --purple-bg: rgba(168,85,247,0.12);
  --red: #ef4444;
  --red-bg: rgba(239,68,68,0.12);
  --yellow: #eab308;
  --yellow-bg: rgba(234,179,8,0.12);
  --coin: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.6);
  --transition: 0.2s ease;
  --sidebar-w: 260px;
}

html { font-size: 15px; scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }
ul, ol { list-style: none; }

.text-gradient {
  background: linear-gradient(135deg, var(--primary) 0%, #818cf8 50%, #a78bfa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.text-success { color: var(--green); }
.text-danger { color: var(--red); }
.text-warning { color: var(--yellow); }
.text-muted { color: var(--text3); }
.text-primary { color: var(--primary); }
.fw-bold { font-weight: 700; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 12px; }
.mt-4 { margin-top: 24px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 16px; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.9rem;
  transition: var(--transition);
  cursor: pointer;
  border: none;
  text-decoration: none;
  justify-content: center;
}
.btn-primary:hover { background: var(--primary2); transform: translateY(-1px); box-shadow: 0 4px 20px var(--primary-glow); }
.btn-primary:active { transform: translateY(0); }

.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.9rem;
  transition: var(--transition);
  cursor: pointer;
  text-decoration: none;
  justify-content: center;
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-glow); }

.btn-danger {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; background: var(--red); color: white;
  border-radius: var(--radius); font-weight: 600; font-size: 0.9rem;
  transition: var(--transition); cursor: pointer; border: none;
}
.btn-danger:hover { opacity: 0.85; }
.btn-success { background: var(--green); color: white; }

.btn-full { width: 100%; }
.btn-lg { padding: 14px 28px; font-size: 1rem; border-radius: var(--radius-lg); }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; border-radius: var(--radius-sm); }

.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--bg4); color: var(--text2); transition: var(--transition);
  border: 1px solid var(--border);
}
.btn-icon:hover { background: var(--bg3); color: var(--primary); border-color: var(--primary); }

.btn-spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text2); margin-bottom: 8px; letter-spacing: 0.02em; }
.form-input {
  width: 100%; padding: 11px 14px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 0.9rem;
  transition: var(--transition); outline: none;
  -webkit-appearance: none; appearance: none;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); background: var(--bg2); }
.form-input::placeholder { color: var(--text3); }
.form-input.has-prefix { padding-left: 42px; }
.form-input-sm { width: 70px; padding: 5px 8px; background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-size: 0.85rem; outline: none; }
.form-input-sm:focus { border-color: var(--primary); }
.form-textarea {
  width: 100%; padding: 11px 14px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 0.9rem;
  transition: var(--transition); outline: none; resize: vertical; min-height: 80px;
  -webkit-appearance: none;
}
.form-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.form-select {
  width: 100%; padding: 11px 14px; padding-right: 36px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 0.9rem;
  outline: none; -webkit-appearance: none; appearance: none; cursor: pointer;
  transition: var(--transition);
}
.form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }

.select-wrapper { position: relative; }
.select-wrapper::after {
  content: '';
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  border: 5px solid transparent;
  border-top-color: var(--text3); margin-top: 2px;
  pointer-events: none;
}

.input-wrapper { position: relative; display: flex; align-items: center; }
.input-wrapper .form-input { padding-left: 42px; }
.input-icon { position: absolute; left: 12px; color: var(--text3); flex-shrink: 0; pointer-events: none; }
.input-prefix { position: absolute; left: 12px; color: var(--text3); font-size: 0.9rem; font-weight: 600; pointer-events: none; }
.toggle-pass { position: absolute; right: 12px; color: var(--text3); display: flex; align-items: center; }
.toggle-pass:hover { color: var(--text); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px; font-size: 0.75rem;
  font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
}
.badge-success { background: var(--green-bg); color: var(--green); }
.badge-danger { background: var(--red-bg); color: var(--red); }
.badge-warning { background: var(--yellow-bg); color: var(--yellow); }
.badge-info { background: var(--blue-bg); color: var(--blue); }
.badge-muted { background: var(--bg4); color: var(--text3); }
.badge-primary { background: var(--primary-glow); color: var(--primary); }
.badge-required { background: var(--red-bg); color: var(--red); padding: 2px 8px; font-size: 0.7rem; }
.badge-lg { padding: 6px 16px; font-size: 0.85rem; }

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: var(--transition);
}

.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 0.88rem; }
.alert-danger { background: var(--red-bg); border: 1px solid rgba(239,68,68,0.3); color: var(--red); }
.alert-success { background: var(--green-bg); border: 1px solid rgba(34,197,94,0.3); color: var(--green); }
.alert-info { background: var(--blue-bg); border: 1px solid rgba(59,130,246,0.3); color: var(--blue); }

.logo-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; background: var(--primary);
  border-radius: 8px; color: white; font-weight: 900; font-size: 1rem;
}
.logo-text { font-size: 1.2rem; font-weight: 800; letter-spacing: -0.02em; }
.logo-dot { color: var(--primary); }

#toast-container {
  position: fixed; bottom: 24px; right: 16px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius);
  background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text); font-size: 0.88rem; font-weight: 500;
  max-width: 320px; min-width: 220px;
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease forwards;
  pointer-events: all;
}
.toast.leaving { animation: toastOut 0.3s ease forwards; }
.toast-success { border-left: 3px solid var(--green); }
.toast-error { border-left: 3px solid var(--red); }
.toast-info { border-left: 3px solid var(--blue); }
.toast-warning { border-left: 3px solid var(--yellow); }

@keyframes toastIn { from { opacity: 0; transform: translateX(20px) translateY(0); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateX(20px); } }

.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 32px 16px; color: var(--text3); text-align: center;
}
.empty-state.large { padding: 56px 16px; }
.empty-state svg { opacity: 0.4; }
.empty-state h3 { color: var(--text2); font-size: 1rem; }
.empty-state p { font-size: 0.88rem; }
.empty-td { text-align: center; padding: 32px; color: var(--text3); }

.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table th {
  text-align: left; padding: 10px 14px;
  font-size: 0.75rem; font-weight: 700; color: var(--text3);
  letter-spacing: 0.05em; text-transform: uppercase;
  border-bottom: 1px solid var(--border); white-space: nowrap;
  background: var(--bg3);
}
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }

.order-id-badge { font-family: 'Fira Code', monospace; font-size: 0.78rem; background: var(--bg4); padding: 3px 8px; border-radius: 6px; color: var(--primary); }
.service-name { font-weight: 500; color: var(--text); }
.target-text { max-width: 200px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text2); font-size: 0.82rem; }
.date-text { color: var(--text3); font-size: 0.82rem; white-space: nowrap; }
.user-tag { color: var(--primary); font-weight: 500; font-size: 0.85rem; }
.coin-amount { color: var(--red); font-weight: 600; }
.text-muted-sm { font-size: 0.78rem; color: var(--text3); }

.pagination { display: flex; gap: 6px; padding: 16px 0 4px; justify-content: center; flex-wrap: wrap; }
.page-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  font-size: 0.85rem; font-weight: 600; color: var(--text2);
  background: var(--bg3); border: 1px solid var(--border);
  transition: var(--transition);
}
.page-btn:hover, .page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-btn {
  padding: 7px 16px; border-radius: 20px; font-size: 0.82rem; font-weight: 600;
  background: var(--bg3); border: 1px solid var(--border); color: var(--text2);
  transition: var(--transition); cursor: pointer;
}
.filter-btn:hover, .filter-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

.action-btns { display: flex; gap: 6px; }
.inline-edit { display: flex; align-items: center; gap: 4px; }

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 16px;
}
.modal-card {
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: var(--radius-lg); padding: 24px;
  width: 100%; max-width: 400px; box-shadow: var(--shadow-lg);
}
.modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }

.search-bar { margin-bottom: 16px; }
.search-bar .input-wrapper .form-input { padding-left: 42px; }

.cat-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cat-title { font-size: 0.95rem; font-weight: 700; color: var(--text2); }
.cat-count { font-size: 0.78rem; color: var(--text3); background: var(--bg4); padding: 2px 8px; border-radius: 20px; }

.header-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.markup-alert {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; background: var(--blue-bg); border: 1px solid rgba(59,130,246,0.25);
  border-radius: var(--radius); color: var(--blue); font-size: 0.85rem; margin-bottom: 16px;
}

.user-cell { display: flex; align-items: center; gap: 10px; }
.user-name-sm { font-weight: 600; font-size: 0.88rem; }
.user-fn { font-size: 0.78rem; color: var(--text3); }
.user-avatar-sm {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 800; color: white; flex-shrink: 0;
}

.debug-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-bottom: 16px; }
.debug-list { display: flex; flex-direction: column; gap: 10px; }
.debug-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.debug-item:last-child { border-bottom: none; }
.debug-key { color: var(--text3); font-size: 0.85rem; }
.debug-val { font-size: 0.85rem; color: var(--text); font-family: 'Fira Code', 'JetBrains Mono', monospace; }
.debug-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.debug-output { margin-top: 16px; padding: 12px; background: var(--bg3); border-radius: var(--radius); font-family: monospace; font-size: 0.85rem; color: var(--green); border: 1px solid var(--border); }

.form-row { display: flex; gap: 10px; }
.back-btn { display: inline-flex; align-items: center; gap: 6px; color: var(--text3); font-size: 0.85rem; transition: var(--transition); margin-bottom: 4px; }
.back-btn:hover { color: var(--primary); }

.ticket-list { display: flex; flex-direction: column; gap: 10px; }
.ticket-card {
  display: block; padding: 16px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); transition: var(--transition); cursor: pointer;
}
.ticket-card:hover { border-color: var(--primary); transform: translateX(2px); }
.ticket-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.ticket-id { font-family: monospace; font-size: 0.78rem; color: var(--text3); }
.ticket-subject { font-weight: 600; font-size: 0.95rem; margin-bottom: 8px; }
.ticket-meta { display: flex; align-items: center; gap: 10px; font-size: 0.8rem; color: var(--text3); }
.ticket-date { margin-left: auto; }
.ticket-msgs { color: var(--text3); }
.ticket-closed-notice { display: flex; align-items: center; gap: 8px; padding: 12px; background: var(--bg3); border-radius: var(--radius); color: var(--text3); font-size: 0.88rem; }

.badge-priority { padding: 2px 8px; border-radius: 20px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; }
.priority-low { background: var(--green-bg); color: var(--green); }
.priority-medium { background: var(--yellow-bg); color: var(--yellow); }
.priority-high { background: var(--red-bg); color: var(--red); }

.ticket-chat-container { display: flex; flex-direction: column; gap: 16px; }
.chat-messages { display: flex; flex-direction: column; gap: 12px; max-height: 450px; overflow-y: auto; padding: 4px; }
.chat-bubble { max-width: 80%; padding: 12px 16px; border-radius: 16px; }
.bubble-user { align-self: flex-end; background: var(--primary-glow); border: 1px solid rgba(91,94,244,0.3); border-bottom-right-radius: 4px; }
.bubble-admin { align-self: flex-start; background: var(--bg3); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble-sender { font-size: 0.72rem; font-weight: 700; color: var(--text3); margin-bottom: 4px; }
.bubble-text { font-size: 0.9rem; color: var(--text); white-space: pre-wrap; }
.bubble-time { font-size: 0.72rem; color: var(--text3); margin-top: 4px; text-align: right; }
.chat-input-area { display: flex; gap: 10px; align-items: flex-end; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.chat-input-area .form-textarea { flex: 1; min-height: 60px; border: none; background: transparent; resize: none; margin: 0; }
.chat-input-area .form-textarea:focus { box-shadow: none; }

.profile-grid { display: grid; grid-template-columns: 280px 1fr; gap: 16px; }
.profile-card { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.profile-avatar-lg {
  width: 72px; height: 72px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-weight: 900; color: white; margin-bottom: 4px;
}
.profile-username { font-size: 1.1rem; font-weight: 700; }
.profile-email { color: var(--text3); font-size: 0.85rem; }
.profile-coin-badge { display: flex; align-items: center; gap: 6px; color: var(--coin); font-weight: 700; font-size: 1rem; }
.profile-meta { font-size: 0.82rem; color: var(--text3); }
.profile-forms { display: flex; flex-direction: column; gap: 16px; }
.api-key-box {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); font-family: 'Fira Code', 'JetBrains Mono', monospace; font-size: 0.82rem; color: var(--text2);
  word-break: break-all;
}
.card-section-title { font-size: 0.95rem; font-weight: 700; margin-bottom: 16px; color: var(--text); }

.error-page { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; text-align: center; padding: 24px; gap: 16px; position: relative; z-index: 1; }
.error-code { font-size: 6rem; font-weight: 900; background: linear-gradient(135deg, var(--primary), var(--purple)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; line-height: 1; font-family: 'Fira Code', 'JetBrains Mono', monospace; }
.error-title { font-size: 1.5rem; font-weight: 700; }
.error-desc { color: var(--text3); max-width: 300px; }

code { font-family: 'Fira Code', 'JetBrains Mono', monospace; font-size: 0.85em; background: var(--bg4); padding: 2px 6px; border-radius: 4px; color: var(--primary); }

.services-filter { margin-bottom: 16px; }
.svc-name-cell { }
.svc-price-sub { font-size: 0.72rem; color: var(--text3); margin-top: 2px; }
.service-note { font-size: 0.8rem; color: var(--text3); margin-top: 2px; }
.text-muted { color: var(--text3); }
.text-muted-sm { font-size: 0.78rem; color: var(--text3); }
.quick-amounts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.quick-amt { padding: 6px 12px; background: var(--bg3); border: 1px solid var(--border); border-radius: 20px; font-size: 0.78rem; font-weight: 600; color: var(--text2); cursor: pointer; transition: all 0.2s; }
.quick-amt:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-glow); }

@media (max-width: 768px) {
  .profile-grid { grid-template-columns: 1fr; }
  .profile-card { flex-direction: row; text-align: left; gap: 16px; }
  .profile-avatar-lg { flex-shrink: 0; }
  .data-table th, .data-table td { padding: 8px 10px; }
}

/* ============ PAGE LOADER ============ */
#page-loader {
  position: fixed;
  inset: 0;
  background: #0a0a0f;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}
#page-loader.pl-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.pl-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.pl-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  animation: plFadeIn 0.4s ease forwards;
}
.pl-logo svg {
  flex-shrink: 0;
  filter: drop-shadow(0 4px 16px rgba(91,94,244,0.5));
  animation: plPulse 2s ease-in-out infinite;
}
.pl-brand {
  font-family: 'Space Grotesk', 'JetBrains Mono', monospace;
  font-size: 1.15rem;
  font-weight: 700;
  color: #e8e8f0;
  letter-spacing: 0.03em;
}
.pl-bar-track {
  width: 120px;
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 10px;
  overflow: hidden;
}
.pl-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #5b5ef4, #a855f7, #5b5ef4);
  background-size: 200% 100%;
  border-radius: 10px;
  animation: plBarFill 1.8s cubic-bezier(0.4,0,0.2,1) forwards,
             plBarShimmer 1.5s linear infinite;
}
@keyframes plFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes plPulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.06); }
}
@keyframes plBarFill {
  0%   { width: 0%; }
  30%  { width: 45%; }
  70%  { width: 75%; }
  90%  { width: 90%; }
  100% { width: 100%; }
}
@keyframes plBarShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
