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

:root {
    --primary-red: #E53E3E;
    --dark-red: #C53030;
    --gold: #D69E2E;
    --dark-gold: #B7791F;
    --warm-yellow: #F6AD55;
    --light-red: #FEB2B2;
    --bg-color: #FFF5F5;
    --card-bg: #FFFFFF;
    --text-primary: #1A202C;
    --text-secondary: #4A5568;
    --text-muted: #718096;
    --border-color: #FED7D7;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #FFF5F5 0%, #FEFCBF 100%);
    min-height: 100vh;
    color: var(--text-primary);
    -webkit-tap-highlight-color: transparent;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
    padding-bottom: 100px;
}

.header {
    text-align: center;
    padding: 24px 16px;
    position: relative;
    margin-bottom: 16px;
}

.lantern {
    position: absolute;
    font-size: 32px;
    animation: swing 2s ease-in-out infinite;
}

.lantern-left {
    left: 16px;
    top: 8px;
    animation-delay: 0s;
}

.lantern-right {
    right: 16px;
    top: 8px;
    animation-delay: 0.5s;
}

@keyframes swing {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

.title {
    font-size: 28px;
    font-weight: bold;
    color: var(--primary-red);
    text-shadow: 2px 2px 4px rgba(229, 62, 62, 0.2);
}

.stats-card {
    background: linear-gradient(135deg, var(--primary-red) 0%, var(--dark-red) 100%);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin-bottom: 16px;
    box-shadow: var(--shadow-lg);
}

.stat-item {
    text-align: center;
    color: white;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    opacity: 0.9;
}

.stat-divider {
    width: 1px;
    height: 40px;
    background: rgba(255, 255, 255, 0.3);
}

.selected-stats-card {
    background: linear-gradient(135deg, var(--gold) 0%, var(--dark-gold) 100%);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.selected-stats-title {
    color: white;
    font-weight: bold;
    font-size: 14px;
}

.selected-stats-content {
    color: white;
    font-size: 14px;
    display: flex;
    gap: 16px;
    align-items: center;
}

.selected-amount {
    font-weight: bold;
    font-size: 16px;
}

.btn-clear-selection {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-clear-selection:hover {
    background: rgba(255, 255, 255, 0.3);
}

.form-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    border: 2px solid var(--border-color);
}

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

.form-group {
    flex: 1;
}

.form-group label {
    display: block;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.form-group input:focus {
    border-color: var(--primary-red);
    box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.1);
}

.form-actions {
    display: flex;
    gap: 12px;
}

.btn-primary,
.btn-secondary {
    flex: 1;
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    min-height: 48px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-red) 0%, var(--dark-red) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(229, 62, 62, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(229, 62, 62, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--card-bg);
    color: var(--text-secondary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-color);
}

.toolbar {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.search-section {
    flex: 1;
    min-width: 200px;
}

.search-input {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background: white;
    color: var(--text-primary);
    outline: none;
}

.search-input:focus {
    border-color: var(--primary-red);
}

.sort-section {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sort-section label {
    font-size: 14px;
    color: var(--text-secondary);
}

.sort-section select {
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background: white;
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
}

.sort-section select:focus {
    border-color: var(--primary-red);
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.btn-action {
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 40px;
}

.btn-import {
    background: #EBF8FF;
    color: #2B6CB0;
}

.btn-import:hover {
    background: #BEE3F8;
}

.btn-export {
    background: #F0FFF4;
    color: #276749;
}

.btn-export:hover {
    background: #C6F6D5;
}

.btn-clear {
    background: #FFF5F5;
    color: var(--primary-red);
}

.btn-clear:hover {
    background: #FED7D7;
}

.list-container {
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.list-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, #FFF5F5 0%, #FEFCBF 50%, #FFF5F5 100%);
}

.list-title {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-primary);
}

.gift-list {
    max-height: 500px;
    overflow-y: auto;
}

.gift-item {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.2s;
}

.gift-item:hover {
    background: var(--bg-color);
}

.gift-item:last-child {
    border-bottom: none;
}

.gift-item.selected {
    background: linear-gradient(135deg, #FFF5F5 0%, #FEFCBF 100%);
}

.checkbox-container {
    position: relative;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.checkmark {
    width: 24px;
    height: 24px;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s;
}

.checkbox-container input:checked ~ .checkmark {
    background: var(--primary-red);
    border-color: var(--primary-red);
}

.checkmark::after {
    content: '';
    display: none;
    width: 6px;
    height: 12px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-top: -2px;
}

.checkbox-container input:checked ~ .checkmark::after {
    display: block;
}

.gift-info {
    flex: 1;
    min-width: 0;
}

.gift-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.gift-time {
    font-size: 12px;
    color: var(--text-muted);
}

.gift-amount {
    font-size: 20px;
    font-weight: bold;
    color: var(--primary-red);
    white-space: nowrap;
}

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

.gift-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 18px;
    transition: background 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gift-btn-edit {
    background: #EBF8FF;
    color: #2B6CB0;
}

.gift-btn-edit:hover {
    background: #BEE3F8;
}

.gift-btn-delete {
    background: #FFF5F5;
    color: var(--primary-red);
}

.gift-btn-delete:hover {
    background: #FED7D7;
}

.gift-btn:active {
    transform: scale(0.95);
}

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

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-hint {
    font-size: 14px;
    color: var(--text-muted);
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

.modal-header h3 {
    font-size: 18px;
    color: var(--text-primary);
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-color);
    color: var(--text-secondary);
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.modal-close:hover {
    background: var(--border-color);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.import-options {
    margin-bottom: 20px;
}

.radio-container {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.radio-container:has(input:checked) {
    border-color: var(--primary-red);
    background: var(--bg-color);
}

.radio-container input {
    position: absolute;
    opacity: 0;
}

.radio-checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s;
    flex-shrink: 0;
}

.radio-container:has(input:checked) .radio-checkmark {
    border-color: var(--primary-red);
}

.radio-checkmark::after {
    content: '';
    display: none;
    width: 10px;
    height: 10px;
    background: var(--primary-red);
    border-radius: 50%;
}

.radio-container:has(input:checked) .radio-checkmark::after {
    display: block;
}

.clear-warning {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    padding: 20px;
    background: #FFF5F5;
    border: 2px solid #FED7D7;
    border-radius: 12px;
    margin-bottom: 20px;
}

.clear-icon {
    font-size: 48px;
    flex-shrink: 0;
}

.clear-message {
    flex: 1;
}

.clear-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.clear-hint {
    font-size: 14px;
    color: var(--primary-red);
    line-height: 1.4;
}

.preview-container {
    background: var(--bg-color);
    border-radius: 12px;
    padding: 16px;
}

.preview-title {
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.preview-table-wrapper {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 12px;
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    background: white;
}

.preview-table th,
.preview-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.preview-table th {
    background: var(--bg-color);
    font-weight: 600;
    color: var(--text-secondary);
}

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

.preview-info {
    font-size: 14px;
    color: var(--text-secondary);
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
}

.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: white;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    z-index: 2000;
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
    box-shadow: var(--shadow-lg);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: #38A169;
}

.toast.error {
    background: var(--primary-red);
}

.toast.warning {
    background: var(--gold);
}

@media (max-width: 480px) {
    .container {
        padding: 12px;
    }

    .title {
        font-size: 24px;
    }

    .lantern {
        font-size: 24px;
    }

    .stats-card {
        padding: 16px;
    }

    .stat-value {
        font-size: 20px;
    }

    .form-card {
        padding: 16px;
    }

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

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .action-buttons {
        justify-content: space-between;
    }

    .btn-action {
        flex: 1;
        justify-content: center;
    }

    .gift-item {
        flex-wrap: wrap;
    }

    .gift-info {
        flex-basis: calc(100% - 120px);
    }

    .gift-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: 8px;
    }

    .selected-stats-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .selected-stats-content {
        flex-wrap: wrap;
    }
}