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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: #f5f7fa;
    color: #333;
    min-height: 100vh;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

.back-home {
    display: inline-block;
    color: #666;
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 10px;
    transition: color 0.2s;
}

.back-home:hover {
    color: #E74C3C;
}

.page-title {
    text-align: center;
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 24px;
    color: #2c3e50;
}

/* Tab 导航 */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
    justify-content: center;
}

.tab-btn {
    padding: 10px 18px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    color: #666;
}

.tab-btn:hover {
    border-color: #E74C3C;
    color: #E74C3C;
}

.tab-btn.active {
    background: #E74C3C;
    color: #fff;
    border-color: #E74C3C;
}

/* 内容区 */
.content {
    background: #fff;
    border-radius: 16px;
    padding: 28px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

/* 生日输入区 */
.birthday-section,
.custom-age-section {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

/* 生日显示区 */
.birthday-display {
    text-align: center;
    margin-bottom: 16px;
    font-size: 14px;
    color: #666;
    cursor: pointer;
    padding: 8px 16px;
    background: #f8f9fa;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
}

.birthday-display:hover {
    background: #eef1f4;
}

.birthday-value {
    color: #E74C3C;
    font-weight: 600;
}

.birthday-edit {
    color: #999;
    font-size: 12px;
    margin-left: 4px;
}

.birthday-display-wrapper {
    text-align: center;
    margin-bottom: 16px;
}

.birthday-section label,
.custom-age-section label {
    font-size: 14px;
    color: #555;
}

#birthdayInput,
#ageSelect {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#birthdayInput:focus,
#ageSelect:focus {
    border-color: #E74C3C;
}

.age-input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    width: 80px;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
}

.age-input:focus {
    border-color: #E74C3C;
}

.age-sep {
    font-size: 14px;
    color: #999;
}

.age-unit {
    font-size: 14px;
    color: #666;
}

.btn-primary {
    padding: 8px 20px;
    background: #E74C3C;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: #c0392b;
}

/* 天/周切换 */
.granularity-toggle {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    gap: 0;
}

.gran-btn {
    padding: 8px 24px;
    border: 1px solid #ddd;
    background: #fff;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.gran-btn:first-child {
    border-radius: 6px 0 0 6px;
}

.gran-btn:last-child {
    border-radius: 0 6px 6px 0;
    border-left: none;
}

.gran-btn.active {
    background: #E74C3C;
    color: #fff;
    border-color: #E74C3C;
}

/* 数据摘要 */
.summary {
    margin-bottom: 24px;
    position: relative;
}

/* 右上角小二维码 */
.mini-qrcode {
    position: absolute;
    top: 16px;
    right: 12px;
    width: 44px;
    height: 44px;
    cursor: pointer;
    padding: 2px;
    background: #fff;
    border: 1px solid #f0f0f0;
    border-radius: 4px;
    opacity: 0.45;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 2;
}

.mini-qrcode:hover {
    opacity: 1;
    transform: scale(1.1);
}

.mini-qrcode img,
.mini-qrcode canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.summary-title {
    font-size: 20px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 20px;
    color: #2c3e50;
}

.summary-stats {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    margin-bottom: 16px;
}

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

.stat-label {
    font-size: 14px;
    color: #888;
    margin-bottom: 6px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-item.past .stat-value {
    color: #E74C3C;
}

.stat-item.remaining .stat-value {
    color: #2ECC71;
}

.stat-percent {
    font-size: 14px;
    color: #999;
}

.stat-divider {
    width: 1px;
    height: 50px;
    background: #eee;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #ecf0f1;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 24px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #E74C3C, #c0392b);
    border-radius: 4px;
    transition: width 0.5s ease;
    width: 0%;
}

/* 方格图表 */
.chart-container {
    display: flex;
    justify-content: center;
    padding: 16px 0;
    overflow-x: auto;
}

#gridCanvas {
    max-width: 100%;
    height: auto;
}

/* 导出区底部文字 */
.export-footer {
    text-align: center;
    padding-top: 8px;
    padding-bottom: 4px;
}

.footer-divider {
    height: 1px;
    background: #eee;
    margin: 16px 20px 18px;
}

.footer-text {
    font-size: 15px;
    color: #888;
    margin: 0 0 12px;
    letter-spacing: 0.5px;
}

/* 保存按钮（在内容框外） */
.action-section {
    text-align: center;
    margin-top: 20px;
    margin-bottom: 8px;
}

.btn-save {
    padding: 12px 40px;
    background: #2ECC71;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(46, 204, 113, 0.3);
}

.btn-save:hover {
    background: #27ae60;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.4);
}

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

.btn-save:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* 页脚 */
.footer {
    text-align: center;
    margin-top: 24px;
    color: #999;
    font-size: 12px;
}

/* 二维码弹框 */
.qrcode-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.qrcode-modal.show {
    display: flex;
}

.qrcode-modal-mask {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.qrcode-modal-content {
    position: relative;
    background: #fff;
    border-radius: 16px;
    padding: 36px 40px 28px;
    text-align: center;
    max-width: 320px;
    width: 90%;
    animation: modalFadeIn 0.25s ease;
}

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

.qrcode-modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

.qrcode-modal-close:hover {
    color: #333;
}

.qrcode-modal-body {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.qrcode-modal-body img,
.qrcode-modal-body canvas {
    width: 220px;
    height: 220px;
}

.qrcode-modal-text {
    font-size: 15px;
    color: #666;
    margin: 0;
    line-height: 1.6;
}

/* 图片预览弹框（微信长按保存） */
.preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.preview-modal.show {
    display: flex;
}

.preview-modal-mask {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
}

.preview-modal-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.preview-modal-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    font-size: 36px;
    color: #fff;
    cursor: pointer;
    line-height: 1;
    padding: 4px 10px;
    z-index: 10;
    opacity: 0.8;
}

.preview-modal-close:hover {
    opacity: 1;
}

.preview-modal-img {
    max-width: 100%;
    max-height: calc(100vh - 100px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-modal-img img {
    max-width: 100%;
    max-height: calc(100vh - 100px);
    object-fit: contain;
    border-radius: 4px;
}

.preview-modal-tip {
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    margin: 16px 0 0;
    text-align: center;
}

/* 响应式 */
@media (max-width: 600px) {
    .container {
        padding: 12px;
    }

    .page-title {
        font-size: 22px;
    }

    .content {
        padding: 16px;
    }

    .summary-stats {
        gap: 20px;
    }

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

    .tab-btn {
        padding: 8px 12px;
        font-size: 12px;
    }
}
