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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Минималистичный фон */
.gradient-bg {
    min-height: 100vh;
    background: linear-gradient(135deg, #e0e7ff 0%, #f3f4f6 50%, #fce7f3 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.container {
    width: 100%;
    max-width: 480px;
}

/* Карточка */
.card {
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.08);
    padding: 2.5rem;
    max-width: 480px;
    width: 100%;
    border: 1px solid #e0e7ff;
}

.logo {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

/* Шаги формы */
.step h2 {
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
    color: #1e293b;
    margin-bottom: 0.75rem;
    letter-spacing: -0.01em;
}

.description {
    font-size: 0.875rem;
    color: #64748b;
    text-align: center;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.note {
    font-size: 0.75rem;
    color: #6366f1;
    text-align: center;
    margin-bottom: 1.5rem;
}

.gray-text {
    color: #94a3b8;
    text-align: center;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.blue-text {
    color: #6366f1;
    font-weight: 600;
    text-align: center;
    margin-bottom: 0.5rem;
}

/* Поля ввода */
input[type="email"],
input[type="text"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid #e0e7ff;
    border-radius: 0.5rem;
    font-size: 0.9375rem;
    outline: none;
    transition: all 0.15s ease;
    margin-bottom: 1rem;
    background: #f8fafc;
    color: #1e293b;
}

input[type="email"]:focus,
input[type="text"]:focus {
    border-color: #6366f1;
    background: white;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.code-input {
    text-align: center;
    font-family: 'SF Mono', 'Consolas', 'Liberation Mono', monospace;
    font-size: 1rem;
    letter-spacing: 0.05em;
}

/* Кнопки */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 500;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    width: 100%;
    border: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(99, 102, 241, 0.25);
}

.btn-primary:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
}

.btn-primary svg {
    flex-shrink: 0;
}

.btn-secondary {
    background-color: #f1f5f9;
    color: #475569;
    border: 1.5px solid #e2e8f0;
}

.btn-secondary:hover {
    background-color: #e2e8f0;
    border-color: #cbd5e1;
}

.button-group {
    display: flex;
    gap: 0.75rem;
}

.button-group .btn {
    flex: 1;
}

/* Сообщения об ошибках */
.error-message {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    background-color: #fef2f2;
    border: 1.5px solid #fecaca;
    border-radius: 0.5rem;
    color: #dc2626;
    font-size: 0.875rem;
    display: none;
}

.error-message.show {
    display: block;
}

/* Progress Bar */
.progress-bar {
    position: relative;
    width: 100%;
    height: 60px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 0.75rem;
    overflow: hidden;
    margin-bottom: 1rem;
    border: 1.5px solid #e0e7ff;
}

.progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
    transition: width 0.4s ease;
    border-radius: 0.75rem;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.875rem;
    font-weight: 500;
    color: #1e293b;
    z-index: 1;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

/* Spinner Animation */
.spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.spinner circle {
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}

@keyframes dash {
    0% {
        stroke-dashoffset: 0;
    }
    50% {
        stroke-dashoffset: -31.4;
    }
    100% {
        stroke-dashoffset: -62.8;
    }
}

/* Модальное окно */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.12);
    padding: 2.5rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
    border: 1px solid #e0e7ff;
}

.modal-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    color: white;
}

.modal-content h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 1rem;
}

.modal-content .gray-text {
    margin-bottom: 0.5rem;
}

.modal-content .blue-text {
    font-size: 1rem;
    margin-bottom: 1.5rem;
}

/* Иконка успеха */
.success-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #6ee7b7 0%, #10b981 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 2rem auto;
    color: white;
}

.success-text {
    font-size: 1rem;
    color: #64748b;
    margin-bottom: 2rem;
}

/* Админ-панель */
.page {
    display: none;
}

.page.active {
    display: block;
}

.admin-container {
    min-height: 100vh;
    background: #f8fafc;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.admin-header {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    padding: 2rem;
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #e2e8f0;
}

.admin-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.admin-header p {
    color: #64748b;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
}

/* Статистика */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.stat-icon.blue { background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%); }
.stat-icon.green { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }
.stat-icon.gray { background: linear-gradient(135deg, #64748b 0%, #475569 100%); }
.stat-icon.purple { background: linear-gradient(135deg, #ec4899 0%, #db2777 100%); }
.stat-icon.red { background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); }

.stat-title {
    color: #64748b;
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.02em;
}

/* Форма добавления кода */
.add-code-form {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    padding: 1.75rem;
    margin-bottom: 1.5rem;
    border: 1px solid #e2e8f0;
}

.add-code-form h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #0f172a;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.875rem;
}

.add-code-form form {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.add-code-form input {
    flex: 1;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
}

.add-code-form input:focus {
    background: white;
    border-color: #6366f1;
}

.add-code-form button {
    width: auto;
    white-space: nowrap;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
}

/* Таблица кодов */
.codes-table {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    border: 1px solid #e2e8f0;
    margin-bottom: 2rem;
}

.codes-table h3 {
    padding: 1.5rem 1.5rem 0 1.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #0f172a;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

th {
    padding: 1rem 1.5rem;
    text-align: left;
    font-size: 0.6875rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tbody tr {
    border-bottom: 1px solid #f1f5f9;
    transition: background-color 0.15s ease;
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr:hover {
    background-color: #f8fafc;
}

td {
    padding: 1rem 1.5rem;
    font-size: 0.875rem;
    color: #0f172a;
    vertical-align: middle;
}

.code-cell {
    font-family: 'SF Mono', 'Consolas', 'Liberation Mono', monospace;
    color: #6366f1;
    font-weight: 600;
    font-size: 0.8125rem;
}

.copy-btn {
    color: #6366f1;
    background: #f1f5f9;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    transition: all 0.15s ease;
    font-weight: 500;
}

.copy-btn:hover {
    background: #e2e8f0;
    color: #4f46e5;
}

.status-badge {
    display: inline-flex;
    padding: 0.375rem 0.75rem;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.status-badge.available {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.used {
    background: #e2e8f0;
    color: #475569;
}

.status-badge.failed {
    background: #fee2e2;
    color: #991b1b;
}

.reset-btn {
    color: #6366f1;
    background: #ede9fe;
    border: none;
    cursor: pointer;
    font-size: 0.8125rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    transition: all 0.15s ease;
    font-weight: 500;
}

.reset-btn:hover {
    background: #ddd6fe;
    color: #4f46e5;
}

.delete-btn {
    color: #ef4444;
    background: #fee2e2;
    border: none;
    cursor: pointer;
    font-size: 0.8125rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    transition: all 0.15s ease;
    font-weight: 500;
}

.delete-btn:hover {
    background: #fecaca;
    color: #dc2626;
}

/* Responsive */
@media (max-width: 768px) {
    .button-group {
        flex-direction: column;
    }

    .add-code-form form {
        flex-direction: column;
    }

    .add-code-form button {
        width: 100%;
    }

    .codes-table {
        overflow-x: auto;
    }

    table {
        min-width: 800px;
    }
}
