:root {
    --bg-base: #0f1115;
    --bg-panel: rgba(26, 29, 36, 0.6);
    --bg-panel-hover: rgba(35, 39, 48, 0.8);
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --accent-primary: #8b5cf6;
    --accent-primary-hover: #7c3aed;
    --accent-danger: #ef4444;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --border-color: rgba(255, 255, 255, 0.1);
    --border-highlight: rgba(255, 255, 255, 0.2);
    
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(139, 92, 246, 0.3);
    
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    line-height: 1.5;
    overflow: hidden;
    height: 100vh;
}

/* Background Aesthetics */
.bg-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    z-index: -1;
    opacity: 0.4;
    animation: float 20s infinite alternate ease-in-out;
}

/* Fullscreen Auth Overlay */
.auth-screen-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #0b0d11;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.auth-screen-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.auth-card {
    width: 100%;
    max-width: 380px;
    padding: 32px 28px;
    border-radius: var(--radius-lg);
    background: rgba(26, 29, 36, 0.85);
    border: 1px solid var(--border-highlight);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), var(--shadow-glow);
    text-align: center;
    animation: authCardPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes authCardPop {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.auth-header .logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--accent-primary), #4f46e5);
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 1.1rem;
    color: white;
    box-shadow: var(--shadow-glow);
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, var(--accent-primary) 0%, transparent 70%);
    top: -100px;
    left: -100px;
}

.orb-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #3b82f6 0%, transparent 70%);
    bottom: -150px;
    right: -100px;
    animation-delay: -5s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 50px) scale(1.1); }
}

/* Typography */
h1, h2, h3 { font-weight: 600; }
a { color: inherit; text-decoration: none; }

/* Layout */
.app-container {
    display: flex; /* Use flex to easily animate width */
    height: 100vh;
    overflow: hidden;
}

/* Glassmorphism Panel */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
}

/* Sidebar */
.sidebar {
    width: 260px;
    flex-shrink: 0;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    border-right: 1px solid var(--border-color);
    transition: all var(--transition-fast);
    overflow-y: auto;
    height: 100vh;
}

.app-container.sidebar-collapsed .sidebar {
    width: 0;
    padding: 0;
    border-right: none;
    opacity: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent-primary), #3b82f6);
    border-radius: 8px;
    box-shadow: var(--shadow-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-family: monospace;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: -1px;
    user-select: none;
}

.brand h2 {
    font-size: 1.25rem;
    letter-spacing: -0.5px;
}

.brand span {
    color: var(--accent-primary);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-weight: 500;
    transition: all var(--transition-fast);
}

.nav-item svg { width: 20px; height: 20px; }

.nav-item:hover, .nav-item.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.nav-item.active {
    background: rgba(139, 92, 246, 0.1);
    color: var(--accent-primary);
    border: 1px solid rgba(139, 92, 246, 0.2);
}

/* Main Content */
.content {
    flex: 1;
    min-width: 0;
    padding: 24px 36px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 100vh;
    overflow: hidden;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.page-title {
    font-size: 1.8rem;
    margin-bottom: 4px;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
    font-family: inherit;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
    background: var(--accent-primary-hover);
    transform: translateY(-1px);
}

.app-container:not(.sidebar-collapsed) #btn-create-user {
    padding: 10px 12px;
}

.app-container:not(.sidebar-collapsed) #btn-create-user .btn-text {
    display: none;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-icon {
    padding: 8px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-main);
}

/* Users Table Container */
.users-container {
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.table-actions {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-shrink: 0;
}

.input-field {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    padding: 10px 16px;
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all var(--transition-fast);
    width: 100%;
}

.input-field::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.input-field:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
}

#search-input {
    max-width: 300px;
}

.table-responsive {
    overflow-x: auto;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    position: relative;
    border-radius: var(--radius-md);
}

/* Custom scrollbar */
.table-responsive::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.table-responsive::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}
.table-responsive::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}
.table-responsive::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

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

.users-table th {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 10;
    background: #181b22;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.search-filters-row th {
    top: 48px;
    padding: 6px 12px 10px 12px;
    background: #15181e;
    border-bottom: 2px solid rgba(139, 92, 246, 0.3);
}

#btn-toggle-search {
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    transition: all var(--transition-fast);
}

#btn-toggle-search:hover,
#btn-toggle-search.active {
    color: var(--accent-primary);
    background: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.4);
}

.users-table td {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    vertical-align: middle;
    text-align: center;
}

/* Align only username body cells to the left */
.users-table td:nth-child(2) {
    text-align: left;
}

.users-table tbody tr {
    transition: background var(--transition-fast);
}

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

.users-table td strong,
.users-table .user-username {
    color: #a78bfa;
    font-weight: 600;
}

.btn-username-copy {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    padding: 2px 6px;
    margin: -2px -6px;
    border-radius: var(--radius-sm);
    color: inherit;
    font-family: inherit;
    font-size: inherit;
    text-align: left;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-username-copy .copy-icon {
    opacity: 0.3;
    color: var(--text-muted);
    transition: all var(--transition-fast);
}

.btn-username-copy:hover {
    background: rgba(139, 92, 246, 0.12);
}

.btn-username-copy:hover strong {
    color: var(--accent-primary-hover);
}

.btn-username-copy:hover .copy-icon {
    opacity: 1;
    color: var(--accent-primary);
    transform: scale(1.15);
}

.btn-username-copy:active {
    transform: scale(0.97);
}

.btn-tg-copy {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: transparent;
    border: none;
    padding: 3px 6px;
    margin: -3px -6px;
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-tg-copy .copy-icon {
    opacity: 0.25;
    color: var(--text-muted);
    transition: all var(--transition-fast);
}

.btn-tg-copy:hover {
    background: rgba(56, 189, 248, 0.12);
    color: #38bdf8;
}

.btn-tg-copy:hover .copy-icon {
    opacity: 1;
    color: #38bdf8;
    transform: scale(1.15);
}

.btn-tg-copy:active {
    transform: scale(0.97);
}

/* Search Highlight */
mark.search-highlight {
    background-color: rgba(234, 179, 8, 0.35);
    color: #fef08a;
    border-bottom: 2px solid #eab308;
    padding: 0 2px;
    border-radius: 3px;
    font-weight: 700;
}

/* Pagination */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}
.pagination-info {
    font-size: 0.9rem;
    color: var(--text-muted);
}
.pagination-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.btn-icon:disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* Status Badges */
.badge {
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge.active { background: rgba(16, 185, 129, 0.15); color: var(--accent-success); border: 1px solid rgba(16,185,129,0.3); }
.badge.disabled { background: rgba(239, 68, 68, 0.15); color: var(--accent-danger); border: 1px solid rgba(239,68,68,0.3); }
.badge.limited { background: rgba(245, 158, 11, 0.15); color: var(--accent-warning); border: 1px solid rgba(245,158,11,0.3); }
.badge.expired { background: rgba(148, 163, 184, 0.15); color: var(--text-muted); border: 1px solid rgba(148,163,184,0.3); }

/* Online / Offline / Never Status Dot Indicator */
.status-dot-container {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: default;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    position: relative;
    transition: all var(--transition-fast);
}

.status-dot.online {
    background-color: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.7);
}

.status-dot.offline {
    background-color: #ef4444;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}

.status-dot.never {
    background-color: #f59e0b;
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.4);
}

/* Payment Stats & Badges */
.payment-stats-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all var(--transition-fast);
    user-select: none;
}

.payment-stats-pill:hover {
    border-color: rgba(16, 185, 129, 0.45);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.12);
}

.payment-stats-pill .payment-icon {
    display: flex;
    align-items: center;
    color: var(--accent-success);
}

.payment-stats-pill .payment-paid-value {
    color: var(--accent-success);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.payment-stats-pill .payment-total-value {
    color: var(--text-muted);
    font-size: 0.9em;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* User Table Payment Badges */
.badge-payment {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
    outline: none;
    font-variant-numeric: tabular-nums;
    text-decoration: none;
}

.badge-payment.paid {
    background: rgba(16, 185, 129, 0.18);
    color: var(--accent-success);
    border: 1px solid rgba(16, 185, 129, 0.45);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.12);
}

.badge-payment.paid:hover {
    background: rgba(16, 185, 129, 0.28);
    border-color: rgba(16, 185, 129, 0.65);
    transform: translateY(-1px);
    box-shadow: 0 3px 12px rgba(16, 185, 129, 0.25);
}

.badge-payment.unpaid {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px dashed rgba(255, 255, 255, 0.25);
}

.badge-payment.unpaid:hover {
    background: rgba(16, 185, 129, 0.12);
    color: var(--accent-success);
    border: 1px solid rgba(16, 185, 129, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.15);
}

/* Progress Bar */
.progress-bar-bg {
    background: rgba(0,0,0,0.3);
    border-radius: var(--radius-full);
    height: 6px;
    width: 100%;
    margin-top: 6px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: var(--radius-full);
    background: var(--accent-primary);
    transition: width 0.3s ease;
}

.progress-bar-fill.warning { background: var(--accent-warning); }
.progress-bar-fill.danger { background: var(--accent-danger); }

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
}

#modal-confirm {
    z-index: 1100;
}

.modal-backdrop.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    width: 100%;
    max-width: 500px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transform: translateY(20px) scale(0.95);
    transition: transform var(--transition-fast);
}

.modal-backdrop.active .modal {
    transform: translateY(0) scale(1);
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 { font-size: 1.25rem; }

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.btn-close:hover { color: var(--text-main); }

.modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
}

.form-group small {
    color: #64748b;
    font-size: 0.8rem;
}

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

.modal-footer {
    padding: 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Loading & Empty States */
.loading-state, .empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(15, 17, 21, 0.7);
    border-radius: var(--radius-lg);
    z-index: 10;
    gap: 16px;
}

.hidden { display: none !important; }

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

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

/* Toasts */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 2000;
}

.toast {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    padding: 16px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateX(100%);
    opacity: 0;
    animation: slideIn 0.3s forwards cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.success { border-left: 4px solid var(--accent-success); }
.toast.error { border-left: 4px solid var(--accent-danger); }
.toast.fade-out { animation: fadeOut 0.3s forwards; }

@keyframes slideIn {
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    to { opacity: 0; transform: translateY(10px); }
}

/* User Context Actions */
.actions-cell {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

/* HWID Limit Clickable Button */
.btn-hwid-limit {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-main);
    font-weight: 500;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-hwid-limit:hover {
    background: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.4);
    color: var(--accent-primary);
    transform: translateY(-1px);
}

/* Green highlight when user has active connected devices */
.btn-hwid-limit.has-devices {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-success);
    border: 1px solid rgba(16, 185, 129, 0.3);
    font-weight: 600;
}

.btn-hwid-limit.has-devices:hover {
    background: rgba(16, 185, 129, 0.25);
    border-color: rgba(16, 185, 129, 0.5);
    color: var(--accent-success);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}

/* HWID Devices Modal Styles */
.hwid-devices-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.hwid-device-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    transition: all var(--transition-fast);
}

.hwid-device-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.15);
}

.hwid-device-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
}

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

.hwid-device-platform {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-main);
}

.hwid-device-tag {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent-primary);
    border: 1px solid rgba(139, 92, 246, 0.25);
}

.hwid-device-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.hwid-device-val {
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    word-break: break-all;
    display: inline-block;
    max-width: 100%;
}

/* Scoped state inside HWID modal body */
#hwid-devices-loading,
#hwid-devices-empty {
    position: static;
    inset: auto;
    background: transparent;
    z-index: 1;
    padding: 40px 20px;
}

/* Views */
.view-active {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: column;
}

.view-hidden {
    display: none;
}

#view-users {
    overflow: hidden;
}

#view-statistics {
    overflow-y: auto;
}

/* Statistics View */
.stats-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.platform-pie-layout {
    display: flex;
    flex-direction: row;
    gap: 40px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.platform-pie-chart-wrapper {
    position: relative;
    width: 100%;
    max-width: 600px;
    height: 400px;
    flex-shrink: 0;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
}

.platform-pie-hole {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 95px;
    height: 95px;
    background: transparent;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.platform-pie-total-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.platform-pie-total-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}

.platform-legend-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    min-width: 250px;
}

.platform-legend-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.platform-legend-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.platform-legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.platform-legend-name {
    font-weight: 500;
    color: #fff;
}

.platform-legend-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.platform-legend-count {
    font-weight: 600;
    color: #fff;
}

.platform-legend-percent {
    color: var(--text-muted);
    font-size: 0.9rem;
    width: 45px;
    text-align: right;
}

.platform-sub-stats {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.platform-sub-stats span {
    display: inline-flex;
    gap: 4px;
}

.stats-list-view {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stats-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all var(--transition-fast);
}

.stats-card:hover {
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.stats-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
}

.stats-card-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-success);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stats-card-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stats-card-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.stats-list-view .stats-card {
    flex-direction: row;
    align-items: center;
    padding: 16px 20px;
    justify-content: space-between;
}

.stats-list-view .stats-card-header {
    min-width: 200px;
}

.stats-list-view .stats-card-value {
    font-size: 1.5rem;
    margin-left: auto;
}

/* ============================================
   RESPONSIVE / MOBILE ADAPTATION
   ============================================ */

/* Sidebar backdrop (created by JS on mobile) */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-backdrop.active {
    opacity: 1;
}

/* ---- Tablets & small desktops (≤ 1024px) ---- */
@media (max-width: 1024px) {

    /* Sidebar: overlay instead of fixed column */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 999;
        height: 100vh;
        width: 260px;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border-right: 1px solid var(--border-color);
        background: rgba(15, 17, 21, 0.97);
    }

    /* When sidebar is open */
    .app-container.sidebar-open .sidebar {
        transform: translateX(0);
    }

    /* Override desktop collapsed state on mobile */
    .app-container.sidebar-collapsed .sidebar {
        width: 260px;
        padding: 24px;
        border-right: 1px solid var(--border-color);
        opacity: 1;
        transform: translateX(-100%);
    }

    .app-container.sidebar-collapsed.sidebar-open .sidebar {
        transform: translateX(0);
    }

    /* Show backdrop on mobile */
    .sidebar-backdrop {
        display: block;
        pointer-events: none;
    }

    .sidebar-backdrop.active {
        pointer-events: all;
    }

    /* Content: full width */
    .content {
        padding: 16px 20px;
    }

    /* Hide "Create User" button text on tablet */
    #btn-create-user .btn-text {
        display: none;
    }

    #btn-create-user {
        padding: 10px 12px;
    }

    /* Users container padding reduced */
    .users-container {
        padding: 16px;
    }
}

/* ---- Phones landscape & small tablets (≤ 768px) ---- */
@media (max-width: 768px) {

    /* Content area */
    .content {
        padding: 12px 14px;
        gap: 14px;
    }

    /* Topbar: stack layout */
    .topbar {
        flex-wrap: wrap;
        gap: 12px;
    }

    .page-title {
        font-size: 1.3rem;
    }

    /* Hide btn-text labels on small screens */
    .btn-text {
        display: none !important;
    }

    /* Smaller buttons */
    .btn {
        padding: 8px 14px;
        font-size: 0.88rem;
    }

    /* Form rows: single column */
    .form-row {
        grid-template-columns: 1fr;
    }

    /* Modals: almost full width */
    .modal {
        max-width: 95vw !important;
        max-height: 90vh;
        margin: 0 10px;
    }

    .modal-body {
        max-height: 60vh;
        overflow-y: auto;
    }

    .modal-header {
        padding: 16px 20px;
    }

    .modal-header h2 {
        font-size: 1.1rem;
    }

    .modal-body {
        padding: 16px 20px;
        gap: 16px;
    }

    .modal-footer {
        padding: 16px 20px;
    }

    /* Users container */
    .users-container {
        padding: 12px;
        border-radius: var(--radius-md);
    }

    /* Table cells: reduce padding */
    .users-table th {
        padding: 10px 8px;
        font-size: 0.75rem;
    }

    .users-table td {
        padding: 10px 8px;
        font-size: 0.85rem;
    }

    /* Pagination: wrap */
    .pagination-container {
        flex-wrap: wrap;
        gap: 10px;
        justify-content: center;
    }

    .pagination-info {
        font-size: 0.8rem;
        width: 100%;
        text-align: center;
    }

    /* Statistics grids */
    .stats-cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 14px;
    }

    .platform-pie-layout {
        flex-direction: column;
        gap: 24px;
    }

    .platform-pie-chart-wrapper {
        max-width: 100%;
        height: 280px;
    }

    .platform-legend-container {
        min-width: unset;
        width: 100%;
    }

    /* Payment stats pill */
    .payment-stats-pill {
        padding: 6px 12px;
        font-size: 0.85rem;
    }

    /* Auth card */
    .auth-card {
        padding: 24px 20px;
    }

    /* subscribe.html client dashboard */
    .client-dashboard {
        margin: 16px auto;
        padding: 16px;
    }

    .client-header {
        flex-wrap: wrap;
        gap: 12px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ---- Phones portrait (≤ 480px) ---- */
@media (max-width: 480px) {

    body {
        overflow-x: hidden;
    }

    .content {
        padding: 10px;
        gap: 10px;
    }

    .page-title {
        font-size: 1.15rem;
    }

    /* Topbar: tighter */
    .topbar > div {
        gap: 8px !important;
    }

    /* ---------- TABLE → CARDS TRANSFORMATION ---------- */

    .users-table thead {
        display: none;
    }

    .users-table,
    .users-table tbody,
    .users-table tr,
    .users-table td {
        display: block;
        width: 100%;
    }

    .users-table tr {
        background: rgba(255, 255, 255, 0.02);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        padding: 12px 14px;
        margin-bottom: 10px;
        position: relative;
    }

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

    .users-table td {
        text-align: left !important;
        padding: 5px 0;
        border-bottom: none;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
    }

    /* data-label for each column via nth-child */
    .users-table td::before {
        content: attr(data-label);
        font-size: 0.75rem;
        font-weight: 600;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.5px;
        flex-shrink: 0;
        min-width: 90px;
    }

    /* Column labels */
    .users-table td:nth-child(1)::before { content: "ID"; }
    .users-table td:nth-child(2)::before { content: "User"; }
    .users-table td:nth-child(3)::before { content: "Status"; }
    .users-table td:nth-child(4)::before { content: "Telegram"; }
    .users-table td:nth-child(5)::before { content: "Expires"; }
    .users-table td:nth-child(6)::before { content: "HWID"; }
    .users-table td:nth-child(7)::before { content: "Payment"; }
    .users-table td:nth-child(8)::before { content: ""; min-width: 0; }

    /* Actions cell: full width, centered */
    .users-table td:nth-child(8) {
        justify-content: center;
        padding-top: 8px;
        margin-top: 4px;
        border-top: 1px solid rgba(255, 255, 255, 0.05);
    }

    .actions-cell {
        width: 100%;
        justify-content: center;
    }

    /* ---------- END TABLE → CARDS ---------- */

    /* Pagination */
    .pagination-container {
        flex-direction: column;
        gap: 8px;
        align-items: center;
    }

    .pagination-actions {
        width: 100%;
        justify-content: center;
    }

    /* Buttons: full width in forms */
    .modal-footer {
        flex-direction: column;
        gap: 8px;
    }

    .modal-footer .btn {
        width: 100%;
        justify-content: center;
    }

    /* Users container */
    .users-container {
        padding: 8px;
        border-radius: 8px;
    }

    /* Statistics */
    .stats-cards-grid {
        grid-template-columns: 1fr;
    }

    .stats-card-value {
        font-size: 1.5rem;
    }

    .stats-list-view .stats-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .stats-list-view .stats-card-header {
        min-width: unset;
    }

    .stats-list-view .stats-card-value {
        margin-left: 0;
        font-size: 1.3rem;
    }

    /* Toasts: full-width centered at bottom */
    .toast-container {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }

    .toast {
        font-size: 0.88rem;
        padding: 12px 16px;
    }

    /* Settings / API Config panels */
    #view-api-config .glass-panel,
    #view-app-settings .glass-panel,
    #view-backup-restore .glass-panel {
        padding: 16px;
        border-radius: var(--radius-md);
    }

    /* subscribe.html */
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .client-header {
        flex-direction: column;
        align-items: flex-start;
    }

    /* Background orbs: reduce on mobile for perf */
    .bg-orb {
        opacity: 0.2;
        filter: blur(80px);
    }

    .orb-1 {
        width: 250px;
        height: 250px;
    }

    .orb-2 {
        width: 300px;
        height: 300px;
    }
}
