:root {
  --bg-base: #080310;
  --bg-card: rgba(18, 10, 32, 0.96);
  --bg-card-hover: rgba(26, 14, 46, 0.98);
  --border-card: rgba(147, 51, 234, 0.22);
  --border-subtle: rgba(255, 255, 255, 0.07);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-gold: #facc15;
  --accent-purple: #9333ea;
  --accent-purple-light: #c084fc;
  --accent-green: #22c55e;
  --accent-blue: #3b82f6;
  --accent-orange: #f97316;
  --accent-red: #ef4444;
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-base);
  background-image: 
    radial-gradient(circle at 10% 10%, rgba(147, 51, 234, 0.14) 0%, transparent 45%),
    radial-gradient(circle at 90% 15%, rgba(234, 179, 8, 0.09) 0%, transparent 45%),
    radial-gradient(circle at 50% 90%, rgba(59, 130, 246, 0.06) 0%, transparent 50%);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  padding: 18px 14px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  -webkit-font-smoothing: antialiased;
}

.app-wrapper {
  width: 100%;
  max-width: 1200px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ============================================================ */
/* 1. ADMIN HEADER BAR (CHÍNH XÁC THEO ẢNH MẪU SCREENSHOT 2)    */
/* ============================================================ */
.admin-header-bar {
  background: linear-gradient(135deg, rgba(26, 14, 44, 0.98), rgba(15, 8, 26, 0.98));
  border: 1px solid rgba(234, 179, 8, 0.3);
  border-radius: 12px;
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.header-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-crown {
  font-size: 18px;
}

.header-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--accent-gold);
  letter-spacing: -0.2px;
}

.header-subtitle {
  font-size: 11.5px;
  color: var(--text-secondary);
}

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

.pill-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.pill-green {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #4ade80;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #22c55e;
  box-shadow: 0 0 8px #22c55e;
  animation: pulse-glow 2s infinite ease-in-out;
}

@keyframes pulse-glow {
  0% { opacity: 0.7; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.15); }
  100% { opacity: 0.7; transform: scale(0.9); }
}

.btn-hdr {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-hdr-purple {
  background: linear-gradient(135deg, #7e22ce, #9333ea);
  border: 1px solid rgba(192, 132, 252, 0.45);
  color: #fff;
  box-shadow: 0 4px 12px rgba(147, 51, 234, 0.35);
}

.btn-hdr-purple:hover {
  background: linear-gradient(135deg, #9333ea, #a855f7);
  transform: translateY(-1px);
}

.btn-hdr-dim {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
}

.btn-hdr-dim:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  transform: translateY(-1px);
}

.btn-icon {
  font-size: 12px;
}

/* ============================================================ */
/* 2. TABS NAV                                                  */
/* ============================================================ */
.nav-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(14, 8, 24, 0.85);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid rgba(147, 51, 234, 0.2);
  width: fit-content;
}

.nav-tab-btn {
  background: transparent;
  border: none;
  padding: 7px 14px;
  border-radius: 7px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.nav-tab-btn:hover {
  color: #fff;
}

.nav-tab-btn.active {
  background: rgba(147, 51, 234, 0.4);
  color: #fff;
  box-shadow: 0 0 10px rgba(147, 51, 234, 0.3);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* ============================================================ */
/* 3. ADMIN CARD & TABLE (CHÍNH XÁC THEO SCREENSHOT 1)           */
/* ============================================================ */
.admin-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-card);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-accent-bar {
  color: #a855f7;
  font-size: 16px;
  font-weight: 900;
}

.card-heading {
  font-size: 14.5px;
  font-weight: 700;
  color: #fff;
}

.card-counter {
  font-size: 11.5px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

/* CONTROLS (SEARCH & FILTERS) */
.table-control-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 260px;
  max-width: 380px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--text-muted);
}

.search-input-wrap input {
  width: 100%;
  background: rgba(10, 5, 18, 0.85);
  border: 1px solid rgba(147, 51, 234, 0.25);
  border-radius: 8px;
  padding: 7px 32px 7px 34px;
  color: #fff;
  font-size: 12px;
  font-family: inherit;
  transition: all 0.2s ease;
}

.search-input-wrap input:focus {
  outline: none;
  border-color: #a855f7;
  box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.2);
}

.btn-clear-input {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
}

.filters-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.ctrl-filter-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.ctrl-filter-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.ctrl-filter-btn.active {
  background: rgba(147, 51, 234, 0.35);
  border-color: rgba(168, 85, 247, 0.6);
  color: #fff;
  box-shadow: 0 0 10px rgba(147, 51, 234, 0.25);
}

.dot-status {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.dot-green {
  background: #22c55e;
}

.dot-red {
  background: #ef4444;
}

.dot-bolt {
  color: #fbbf24;
}

.ctrl-refresh-btn {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: #60a5fa;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.ctrl-refresh-btn:hover {
  background: rgba(59, 130, 246, 0.25);
}

.ctrl-refresh-btn.loading .refresh-spinner-icon {
  animation: spin 0.8s linear infinite;
}

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

/* TABLE STYLES */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
}

.admin-table thead th {
  background: rgba(12, 6, 22, 0.75);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(147, 51, 234, 0.15);
}

.admin-table tbody tr {
  transition: background 0.15s ease;
}

.admin-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.admin-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}

/* TABLE CELL CONTENT */
.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #facc15, #eab308);
  color: #000;
  font-weight: 800;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-meta-wrap {
  display: flex;
  flex-direction: column;
}

.user-main-title {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.user-sub-note {
  font-size: 11px;
  color: var(--text-muted);
}

.uid-cell-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.uid-mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.04);
  padding: 2px 6px;
  border-radius: 4px;
}

.btn-copy-action {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 12px;
  opacity: 0.65;
  transition: opacity 0.2s ease;
}

.btn-copy-action:hover {
  opacity: 1;
}

.plan-cell-wrap {
  display: flex;
  flex-direction: column;
}

.plan-badge-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent-gold);
}

.plan-badge-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.status-badges-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 5px;
  white-space: nowrap;
}

.tag-gold-granted {
  background: rgba(147, 51, 234, 0.22);
  border: 1px solid rgba(168, 85, 247, 0.35);
  color: #d8b4fe;
}

.tag-45s-ready {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #34d399;
}

.tag-45s-cache {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fbbf24;
}

.tag-blocked-state {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #f87171;
}

.time-ip-stack {
  display: flex;
  flex-direction: column;
}

.time-val {
  font-size: 11.5px;
  color: #cbd5e1;
}

.ip-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  color: var(--text-muted);
}

/* ACTION BUTTONS (EXACTLY MATCHING SCREENSHOT 1) */
.action-buttons-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-table-lock {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #f87171;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.btn-table-lock:hover {
  background: rgba(239, 68, 68, 0.16);
}

.btn-table-delete {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-table-delete:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.table-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 30px;
  color: var(--text-muted);
  font-size: 12.5px;
}

.loader-circle {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(147, 51, 234, 0.2);
  border-top-color: #a855f7;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.empty-state-wrap {
  padding: 40px 14px;
  text-align: center;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 32px;
  margin-bottom: 6px;
  display: block;
}

.empty-msg {
  font-size: 13px;
}

/* ============================================================ */
/* 4. TAB 2: KHO TÍNH NĂNG (GỌN GÀNG, SẠCH CHỮ, ĐẸP MẮT)         */
/* ============================================================ */
.cat-chip-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.cat-chip-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.cat-chip-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.cat-chip-btn.active {
  background: linear-gradient(135deg, #7e22ce, #9333ea);
  border-color: rgba(192, 132, 252, 0.5);
  color: #fff;
  box-shadow: 0 0 10px rgba(147, 51, 234, 0.35);
}

.clean-apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.app-tile {
  background: rgba(22, 12, 38, 0.9);
  border: 1px solid var(--border-card);
  border-radius: 11px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  transition: all 0.2s ease;
}

.app-tile:hover {
  background: var(--bg-card-hover);
  border-color: rgba(168, 85, 247, 0.45);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

.app-tile.highlight-gold-tile {
  border-color: rgba(234, 179, 8, 0.35);
  background: linear-gradient(135deg, rgba(34, 20, 48, 0.95), rgba(22, 12, 36, 0.95));
}

.app-tile.highlight-shield-tile {
  border-color: rgba(34, 197, 94, 0.35);
  background: linear-gradient(135deg, rgba(16, 32, 26, 0.95), rgba(12, 22, 18, 0.95));
}

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

.tile-icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
}

.tile-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.tile-meta {
  flex: 1;
}

.tile-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.tile-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #fff;
}

.tile-badge {
  font-size: 9.5px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-gold {
  background: rgba(234, 179, 8, 0.2);
  border: 1px solid rgba(250, 204, 21, 0.4);
  color: #fef08a;
}

.badge-green {
  background: rgba(34, 197, 94, 0.2);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #86efac;
}

.badge-green-glow {
  background: rgba(16, 185, 129, 0.25);
  border: 1px solid rgba(16, 185, 129, 0.5);
  color: #6ee7b7;
}

.badge-orange {
  background: rgba(249, 115, 22, 0.2);
  border: 1px solid rgba(249, 115, 22, 0.4);
  color: #fdba74;
}

.badge-blue {
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #93c5fd;
}

.badge-purple {
  background: rgba(147, 51, 234, 0.2);
  border: 1px solid rgba(168, 85, 247, 0.4);
  color: #d8b4fe;
}

.badge-red {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

.tile-chips-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

.mini-perk {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  padding: 3px 7px;
  font-size: 11px;
  color: #e2e8f0;
  font-weight: 500;
}

/* ============================================================ */
/* 5. FOOTER & TOAST                                            */
/* ============================================================ */
.admin-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.footer-online-dot {
  color: #22c55e;
  font-size: 12px;
}

.toast-popup {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: rgba(18, 10, 32, 0.96);
  border: 1px solid #22c55e;
  border-radius: 8px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-size: 12.5px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 9999;
}

.toast-popup.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.toast-dot {
  color: #22c55e;
  font-weight: bold;
}

/* RESPONSIVE */
@media (max-width: 768px) {
  body {
    padding: 12px 8px;
  }
  .admin-header-bar {
    padding: 12px;
  }
  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }
  .table-control-row {
    flex-direction: column;
    align-items: stretch;
  }
  .search-input-wrap {
    max-width: 100%;
  }
  .filters-wrap {
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .clean-apps-grid {
    grid-template-columns: 1fr;
  }
  .admin-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}
