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

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

.main {
    animation: fadeInUp 0.5s ease-out;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(102, 126, 234, 0.03) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: fixed;
    bottom: -50%;
    left: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(118, 75, 162, 0.03) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 30px;
    position: relative;
    z-index: 1;
}

.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid rgba(0,0,0,0.04);
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 30px;
}

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

.logo-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.logo-text h1 {
    font-size: 16px;
    font-weight: 600;
    color: #1a1c20;
}

.logo-text span {
    font-size: 11px;
    color: #888;
}

.nav-menu {
    display: flex;
    gap: 4px;
}

.nav-menu a {
    color: #666;
    text-decoration: none;
    padding: 20px 18px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.25s;
    border-bottom: 3px solid transparent;
}

.nav-menu a:hover {
    color: #667eea;
}

.nav-menu a.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.main {
    padding: 30px 0;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    background: #fff;
    padding: 20px 28px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.page-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: #1a1c20;
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-header h2::before {
    content: '';
    width: 4px;
    height: 24px;
    background: linear-gradient(180deg, #667eea, #764ba2);
    border-radius: 2px;
}

.btn-add {
    padding: 10px 22px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.35);
}

.btn-add:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.45);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border-radius: 16px;
    padding: 22px 24px;
    display: flex;
    align-items: center;
    gap: 18px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    transition: all 0.3s;
    border: 1px solid rgba(0,0,0,0.04);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.3), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(0,0,0,0.1);
}

.stat-icon {
    width: 54px;
    height: 54px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
}

.stat-icon.blue { background: linear-gradient(135deg, #e3f2fd, #bbdefb); }
.stat-icon.green { background: linear-gradient(135deg, #e8f5e9, #c8e6c9); }
.stat-icon.orange { background: linear-gradient(135deg, #fff3e0, #ffe0b2); }
.stat-icon.purple { background: linear-gradient(135deg, #f3e5f5, #e1bee7); }

.stat-info h4 {
    font-size: 13px;
    color: #888;
    font-weight: 500;
    margin-bottom: 4px;
}

.stat-info .value {
    font-size: 26px;
    font-weight: 700;
    color: #1a1c20;
}

.filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    background: #fff;
    padding: 20px 28px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    border: 1px solid rgba(0,0,0,0.04);
}

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

.filter-left label {
    font-size: 14px;
    font-weight: 500;
    color: #666;
}

.filter-left select {
    padding: 8px 16px;
    border: 1.5px solid #e0e0e8;
    border-radius: 8px;
    font-size: 14px;
    color: #333;
    background: #fff;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 160px;
}

.filter-left select:hover {
    border-color: #c0c0d0;
}

.filter-left select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.table-wrapper {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    border: 1px solid rgba(0,0,0,0.04);
    overflow: hidden;
}

.table-wrapper::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.table-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #667eea, #764ba2);
    border-radius: 4px;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #5a6fd6, #6a4190);
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    color: #1a1c20;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.data-table th {
    background: linear-gradient(180deg, #f8f9fa 0%, #f0f2f5 100%);
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: #495057;
    border-bottom: 2px solid #e9ecef;
    position: relative;
}

.data-table th::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    opacity: 0;
    transition: opacity 0.3s;
}

.data-table th:hover::after {
    opacity: 1;
}

.data-table td {
    padding: 14px 16px;
    font-size: 14px;
    color: #1a1c20;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

.data-table tbody tr {
    transition: all 0.2s;
}

.data-table tbody tr:hover {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.04), rgba(118, 75, 162, 0.04));
}

.data-table tbody tr:nth-child(even) {
    background: rgba(248, 249, 250, 0.5);
}

.data-table tbody tr:nth-child(even):hover {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.04), rgba(118, 75, 162, 0.04));
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.cell-name {
    font-weight: 600;
}

.cell-game {
    color: #5566cc;
    font-weight: 500;
}

.cell-wechat {
    color: #888;
}

.cell-number {
    font-weight: 600;
    color: #667eea;
    font-variant-numeric: tabular-nums;
}

.gift-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.gift-count {
    font-weight: 600;
    color: #e65100;
    cursor: pointer;
    padding: 2px 10px;
    background: #fff3e0;
    border-radius: 4px;
    font-size: 13px;
    transition: all 0.2s;
}

.gift-count:hover {
    background: #ffe0b2;
    transform: scale(1.05);
}

.cell-actions {
    display: flex;
    gap: 8px;
}

.btn-action {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.25s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    position: relative;
    overflow: hidden;
}

.btn-action::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.4s, height 0.4s;
}

.btn-action:hover::before {
    width: 200px;
    height: 200px;
}

.btn-edit {
    background: #fff3e0;
    color: #e65100;
}

.btn-edit:hover {
    background: #ffe0b2;
    transform: translateY(-1px);
}

.btn-delete {
    background: #ffebee;
    color: #c62828;
}

.btn-delete:hover {
    background: #ffcdd2;
    transform: translateY(-1px);
}

.btn-grant {
    background: #e8f5e9;
    color: #2e7d32;
}

.btn-grant:hover {
    background: #c8e6c9;
    transform: translateY(-1px);
}

.cell-actions {
    display: flex;
    gap: 8px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #888;
}

.empty-state p {
    font-size: 14px;
    color: #999;
}

.empty-state::before {
    content: '📋';
    display: block;
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.6;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(4px);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: #fff;
    padding: 24px;
    border-radius: 16px;
    width: 500px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0,0,0,0.15);
    animation: modalSlide 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(0,0,0,0.05);
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-content h3 {
    margin-bottom: 20px;
    font-size: 18px;
    color: #1a1c20;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-content h3::before {
    content: '';
    width: 4px;
    height: 20px;
    background: linear-gradient(180deg, #667eea, #764ba2);
    border-radius: 2px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: #505060;
    font-weight: 500;
    font-size: 13px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #e0e0e8;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s;
    background: #fff;
}

.form-group input:hover,
.form-group select:hover {
    border-color: #c0c0d0;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1), 0 2px 8px rgba(102, 126, 234, 0.1);
}

.form-group input::placeholder {
    color: #b0b0c0;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #f0f0f5;
}

.btn-cancel,
.btn-submit {
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
}

.btn-cancel {
    background: #f5f5f7;
    color: #606070;
}

.btn-cancel:hover {
    background: #e8e8ec;
}

.btn-submit {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.code-display {
    background: #f8f9fb;
    border: 1.5px dashed #d0d5e0;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.code-placeholder {
    color: #b0b0c0;
    font-size: 14px;
}

.code-value {
    color: #2e7d32;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 1px;
    word-break: break-all;
}

.code-error {
    color: #c62828;
    font-size: 14px;
}

.btn-copy-code {
    padding: 12px 24px;
    background: linear-gradient(135deg, #43a047 0%, #388e3c 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(67, 160, 71, 0.3);
}

.btn-copy-code:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(67, 160, 71, 0.4);
}

.btn-copy-code:disabled {
    background: #c0c0c8;
    cursor: not-allowed;
    box-shadow: none;
}

.modal-small {
    width: 420px;
}

#recordsList {
    max-height: 350px;
    overflow-y: auto;
}

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

#recordsList th {
    background: #f8f9fa;
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: #495057;
    border-bottom: 2px solid #e9ecef;
}

#recordsList td {
    padding: 14px 16px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
}

#recordsList code {
    background: #e8f5e9;
    padding: 3px 8px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', monospace;
    color: #2e7d32;
    font-size: 12px;
}

@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .header .container {
        flex-direction: column;
        padding: 12px 16px;
        gap: 10px;
    }

    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
    }

    .nav-menu a {
        padding: 10px 12px;
        font-size: 13px;
    }

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

    .page-header {
        flex-direction: column;
        gap: 12px;
    }

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

    .data-table {
        min-width: 700px;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }
}
