:root {
    --tg-bg: var(--tg-theme-bg-color, #fff);
    --tg-text: var(--tg-theme-text-color, #000);
    --tg-hint: var(--tg-theme-hint-color, #707579);
    --tg-link: var(--tg-theme-link-color, #2481cc);
    --tg-button: var(--tg-theme-button-color, #2481cc);
    --tg-button-text: var(--tg-theme-button-text-color, #fff);
    --tg-secondary: var(--tg-theme-secondary-bg-color, #f1f3f5);
    --accent: #667eea;
    --success: #2e7d32;
    --error: #d32f2f;
    --warning: #f57c00;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--tg-bg);
    color: var(--tg-text);
    min-height: 100dvh;
    padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom) 16px;
}

.header {
    text-align: center;
    padding: 30px 0 20px;
}

.header img {
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
    border-radius: 20px;
    object-fit: cover;
}

.header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 6px;
}

.header p {
    color: var(--tg-hint);
    font-size: 16px;
}

.balance {
    font-size: 42px;
    font-weight: 800;
    text-align: center;
    margin: 20px 0;
    color: var(--accent);
}

.status {
    text-align: center;
    padding: 16px;
    border-radius: 16px;
    font-weight: 600;
    font-size: 16px;
    background: rgba(46, 125, 50, 0.12);
    color: var(--success);
    margin-bottom: 24px;
    transition: all 0.3s ease;
}

.status.expired {
    background: rgba(211, 47, 47, 0.12);
    color: var(--error);
}

.status.warning {
    background: rgba(245, 124, 0, 0.12);
    color: var(--warning);
}

.timer {
    font-size: 18px;
    font-weight: 700;
    margin-top: 8px;
}

.tiles {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 24px 0;
}

.tile {
    background: var(--tg-secondary);
    border-radius: 16px;
    padding: 20px 12px;
    text-align: center;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
    cursor: pointer;
    min-height: 110px;
}

.tile:active {
    transform: scale(0.96);
    background: rgba(0, 0, 0, 0.05);
}

.tile img {
    width: 44px;
    height: 44px;
    display: block;
    border-radius: 12px;
    object-fit: cover;
}

.tile .title {
    font-weight: 600;
    font-size: 14px;
    color: var(--tg-text);
}

.tile .value {
    font-weight: 700;
    font-size: 16px;
    color: var(--accent);
}

.tariffs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 24px 0;
}

.tariff-btn {
    background: var(--tg-button);
    color: var(--tg-button-text);
    border: none;
    border-radius: 16px;
    padding: 20px 12px;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.2s ease;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(38, 129, 204, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.tariff-btn:active {
    transform: scale(0.96);
    box-shadow: 0 2px 6px rgba(38, 129, 204, 0.3);
}

.tariff-btn img {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: cover;
}

.btn {
    width: 100%;
    padding: 16px;
    background: var(--tg-button);
    color: var(--tg-button-text);
    border: none;
    border-radius: 16px;
    font-size: 16px;
    font-weight: 600;
    margin: 12px 0;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(38, 129, 204, 0.2);
}

.btn:active {
    transform: scale(0.98);
}

.btn.secondary {
    background: var(--tg-secondary);
    color: var(--tg-text);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn.danger {
    background: var(--error);
    color: white;
}

.referral-link {
    background: var(--tg-secondary);
    padding: 16px;
    border-radius: 16px;
    word-break: break-all;
    font-family: monospace;
    font-size: 14px;
    margin: 20px 0;
    text-align: center;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.user-id {
    background: var(--tg-secondary);
    padding: 16px;
    border-radius: 16px;
    font-family: monospace;
    font-size: 15px;
    margin: 16px 0;
    text-align: center;
    border: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.copy-btn {
    background: var(--tg-button);
    color: var(--tg-button-text);
    border: none;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copy-btn:active {
    transform: scale(0.95);
}

.hidden {
    display: none;
}

h2 {
    text-align: center;
    margin: 30px 0 20px;
    font-size: 24px;
    font-weight: 700;
}

.loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--tg-hint);
    font-size: 16px;
}

.error {
    text-align: center;
    padding: 20px;
    background: rgba(211, 47, 47, 0.1);
    color: var(--error);
    border-radius: 16px;
    margin: 16px 0;
    font-size: 15px;
}

.info-card {
    background: var(--tg-secondary);
    padding: 24px 20px;
    border-radius: 16px;
    text-align: center;
    margin: 20px 0;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.info-card img {
    width: 60px;
    height: 60px;
    margin: 0 auto 20px;
    border-radius: 14px;
    object-fit: cover;
}

.info-card p {
    font-size: 16px;
    margin: 12px 0;
    line-height: 1.4;
}

.highlight {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
    margin: 8px 0;
}

.tariff-price {
    font-size: 18px;
    font-weight: 700;
    margin-top: 4px;
}

.hint {
    color: var(--tg-hint);
    font-size: 14px;
    text-align: center;
    margin: 16px 0;
    line-height: 1.4;
}

.id-section {
    margin: 20px 0;
}

.id-label {
    font-size: 14px;
    color: var(--tg-hint);
    margin-bottom: 8px;
    text-align: center;
}

.admin-btn {
    margin-top: 20px;
    text-align: center;
}

.debug-info {
    background: rgba(0, 0, 0, 0.05);
    padding: 10px;
    border-radius: 8px;
    font-size: 12px;
    color: var(--tg-hint);
    margin: 10px 0;
    word-break: break-all;
}

.purchase-processing {
    text-align: center;
    padding: 20px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 16px;
    margin: 16px 0;
}

.purchase-processing .spinner {
    width: 24px;
    height: 24px;
    border: 2px solid transparent;
    border-top: 2px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.time-fix-notice {
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 8px;
    padding: 8px 12px;
    margin: 8px 0;
    font-size: 12px;
    color: #ff9800;
    text-align: center;
}
/* Стили админ-панели */
.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.admin-stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    padding: 20px;
    color: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
}

.admin-stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.1), transparent);
    transform: rotate(45deg);
    transition: all 0.6s ease;
}

.admin-stat-card:hover::before {
    transform: rotate(45deg) translate(50%, 50%);
}

.admin-stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.admin-stat-label {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 8px;
    font-weight: 500;
}

.admin-stat-value {
    font-size: 24px;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.admin-actions {
    background: white;
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.08);
    margin-bottom: 24px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.admin-input-group {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    align-items: center;
}

.admin-input {
    flex: 1;
    padding: 14px 16px;
    border: 2px solid #eef2ff;
    border-radius: 12px;
    font-size: 16px;
    background: #f8faff;
    transition: all 0.3s ease;
    outline: none;
}

.admin-input:focus {
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.admin-input::placeholder {
    color: #9ca3af;
}

/* Кнопки */
.btn {
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    white-space: nowrap;
}

.btn:not(.secondary):not(.danger) {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn:hover:not(.secondary):not(.danger) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn.danger {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(245, 87, 108, 0.3);
    width: 100%;
    justify-content: center;
    margin-top: 8px;
}

.btn.danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 87, 108, 0.4);
}

.btn.secondary {
    background: #f1f5f9;
    color: #64748b;
    border: 2px solid #e2e8f0;
    width: 100%;
    justify-content: center;
}

.btn.secondary:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

/* Результаты поиска */
.search-results {
    margin: 24px 0;
    transition: all 0.3s ease;
}

.admin-user-card {
    background: white;
    border-radius: 20px;
    padding: 0;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.05);
    overflow: hidden;
    margin-bottom: 20px;
}

.user-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 24px;
    color: white;
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
}

.user-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-info {
    flex: 1;
}

.user-name {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 4px;
}

.user-username {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 4px;
}

.user-id {
    font-size: 12px;
    opacity: 0.7;
}

.user-status {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.2);
}

.user-status.active {
    background: rgba(34, 197, 94, 0.3);
}

.user-status.blocked {
    background: rgba(239, 68, 68, 0.3);
}

.user-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    padding: 24px;
    background: #f8faff;
    border-bottom: 1px solid #eef2ff;
}

.stat-item {
    text-align: center;
}

.stat-label {
    font-size: 12px;
    color: #64748b;
    margin-bottom: 4px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 18px;
    font-weight: bold;
    color: #1e293b;
}

.stat-value.balance {
    color: #10b981;
}

.stat-value.bonus {
    color: #f59e0b;
}

.stat-value.tariff {
    color: #667eea;
    font-size: 14px;
}

.user-actions-header {
    padding: 20px 24px 16px;
    font-size: 16px;
    font-weight: bold;
    color: #1e293b;
    border-bottom: 1px solid #eef2ff;
}

.user-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    padding: 24px;
}

.action-group {
    background: #f8faff;
    border-radius: 12px;
    padding: 16px;
    border: 1px solid #eef2ff;
}

.action-label {
    font-size: 14px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 12px;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.action-btn {
    padding: 12px 16px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    text-align: left;
}

.action-btn.primary {
    background: #667eea;
    color: white;
}

.action-btn.secondary {
    background: #e2e8f0;
    color: #475569;
    border: 1px solid #cbd5e1;
}

.action-btn.success {
    background: #10b981;
    color: white;
}

.action-btn.danger {
    background: #ef4444;
    color: white;
}

.action-btn.warning {
    background: #f59e0b;
    color: white;
}

.action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-icon, .quick-icon {
    font-size: 16px;
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 12px;
    padding: 20px 24px;
    background: #f1f5f9;
    border-top: 1px solid #e2e8f0;
}

.quick-action {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
    color: #475569;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.quick-action:hover {
    border-color: #667eea;
    background: #f8faff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Адаптивность */
@media (max-width: 768px) {
    .admin-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .admin-input-group {
        flex-direction: column;
    }
    
    .admin-input {
        width: 100%;
    }
    
    .user-header {
        flex-direction: column;
        text-align: center;
    }
    
    .user-actions-grid {
        grid-template-columns: 1fr;
    }
    
    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .admin-stats {
        grid-template-columns: 1fr;
    }
    
    .user-stats {
        grid-template-columns: 1fr;
    }
}

/* Анимации */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.admin-user-card {
    animation: fadeIn 0.5s ease;
}

.hidden {
    display: none !important;
}

/* Заголовок */
h2 {
    color: #1e293b;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 24px;
    text-align: center;
    position: relative;
}

h2::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 4px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 2px;
}