/* ========== 全局样式 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --secondary: #764ba2;
    --success: #48bb78;
    --warning: #ed8936;
    --danger: #f56565;
    --info: #4299e1;
    --bg: #f7fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
}

/* ========== 应用容器 ========== */
.app-container {
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ========== 桌面端导航（默认隐藏） ========== */
.desktop-nav {
    display: none;
}

/* ========== 滑动容器 ========== */
.slider-container {
    flex: 1;
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.slider-container::-webkit-scrollbar {
    display: none;
}

/* ========== 页面 ========== */
.page {
    flex: 0 0 100vw;
    scroll-snap-align: start;
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.page-content {
    padding: 12px;
    padding-bottom: 70px;
    height: 100%;
    overflow-y: auto;
}

.page-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 12px;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ========== 概览版面 ========== */
.section-title {
    font-size: 16px;
    font-weight: 700;
    margin: 20px 0 12px 0;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.overview-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.overview-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: var(--shadow);
    text-align: center;
}

.overview-card.total {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.overview-card.settled {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
}

.overview-card.unsettled {
    background: linear-gradient(135deg, #ed8936 0%, #dd6b20 100%);
    color: white;
}

.overview-card.month-total {
    background: linear-gradient(135deg, #9f7aea 0%, #805ad5 100%);
    color: white;
}

.overview-card.month-settled {
    background: linear-gradient(135deg, #68d391 0%, #48bb78 100%);
    color: white;
}

.overview-card.month-unsettled {
    background: linear-gradient(135deg, #fbd38d 0%, #ed8936 100%);
    color: white;
}

.card-icon {
    font-size: 24px;
    margin-bottom: 4px;
}

.card-label {
    font-size: 11px;
    opacity: 0.9;
}

.card-value {
    font-size: 14px;
    font-weight: 700;
}

.progress-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 12px;
    box-shadow: var(--shadow);
}

.progress-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
}

.progress-bar {
    height: 12px;
    background: var(--bg);
    border-radius: 6px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success) 0%, #38a169 100%);
    border-radius: 6px;
    transition: width 0.5s ease;
}

.progress-fill.life-plan {
    background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
}

.progress-fill.month-plan {
    background: linear-gradient(90deg, var(--info) 0%, #3182ce 100%);
}

/* ========== 表单样式 ========== */
.form-group {
    margin-bottom: 10px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--card-bg);
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.select-with-manage {
    display: flex;
    gap: 6px;
}

.select-with-manage select {
    flex: 1;
}

.icon-btn {
    padding: 10px 12px;
    background: var(--info);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
}

.icon-btn.small {
    padding: 6px 10px;
    font-size: 14px;
}

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.toggle-group {
    display: flex;
    gap: 8px;
}

.toggle-btn {
    flex: 1;
    padding: 8px;
    border: 2px solid var(--border);
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--card-bg);
    font-size: 12px;
}

.toggle-btn input {
    display: none;
}

.toggle-btn:has(input:checked) {
    border-color: var(--primary);
    background: rgba(102, 126, 234, 0.1);
}

.toggle-btn span {
    font-weight: 600;
}

.toggle-btn:has(input:checked) span {
    color: var(--primary);
}

.mt-1 {
    margin-top: 6px;
}

.submit-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* ========== 计划版面 ========== */
.plan-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.plan-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 12px;
    box-shadow: var(--shadow);
}

.plan-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.plan-header h3 {
    font-size: 14px;
    font-weight: 700;
}

.plan-progress {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.plan-stats {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-secondary);
}

.plan-stats b {
    font-size: 13px;
    color: var(--text-primary);
}

/* ========== 记录版面 ========== */
.search-bar {
    display: grid;
    grid-template-columns: 1fr 1fr auto auto;
    gap: 6px;
    margin-bottom: 12px;
}

.search-input {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
}

.search-btn {
    padding: 8px 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}

.settled-toggle {
    margin-bottom: 12px;
}

.toggle-settled-btn {
    width: 100%;
    padding: 10px 14px;
    background: linear-gradient(135deg, var(--success) 0%, #38a169 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(72, 187, 120, 0.3);
}

.toggle-settled-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.4);
}

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

.toggle-settled-btn .toggle-icon {
    font-size: 18px;
}

.toggle-settled-btn .toggle-text {
    flex: 1;
    text-align: center;
}

.records-list {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 12px;
    min-height: 200px;
}

.record-item {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.3s ease;
}

.record-item:active {
    transform: scale(0.98);
}

.record-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.record-title {
    font-size: 14px;
    font-weight: 700;
    flex: 1;
}

.record-date {
    font-size: 11px;
    color: var(--text-secondary);
}

.record-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    font-size: 12px;
}

.record-field {
    display: flex;
    flex-direction: column;
}

.record-field.clickable {
    cursor: pointer;
    transition: all 0.2s ease;
}

.record-field.clickable:active {
    transform: scale(0.95);
}

.record-label {
    color: var(--text-secondary);
    font-size: 10px;
}

.record-value {
    font-weight: 600;
}

.record-value.amount {
    color: var(--success);
    font-size: 14px;
}

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 600;
}

.status-badge.settled,
.status-badge.reported {
    background: rgba(72, 187, 120, 0.15);
    color: var(--success);
}

.status-badge.unsettled,
.status-badge.unreported {
    background: rgba(237, 137, 54, 0.15);
    color: var(--warning);
}

.no-data {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-style: italic;
}

.record-times {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.time-info {
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.time-info.settled-time {
    color: var(--success);
    font-weight: 500;
}

.record-remark {
    margin-top: 8px;
    padding: 8px 12px;
    background: var(--bg);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    cursor: pointer;
    transition: all 0.2s ease;
}

.record-remark:active {
    transform: scale(0.98);
}

.record-remark.empty {
    color: var(--primary);
    font-style: italic;
    opacity: 0.8;
}

.data-operations {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.op-btn {
    padding: 12px;
    background: var(--info);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

/* ========== 云同步版面 ========== */
.cloud-config {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 12px;
}

.action-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 10px;
}

.config-btn {
    background: var(--text-primary);
    color: white;
}

.sync-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
}

.cloud-info {
    background: rgba(102, 126, 234, 0.1);
    border-radius: 12px;
    padding: 12px;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.8;
}

/* ========== 底部导航栏 ========== */
.bottom-nav {
    display: flex;
    background: white;
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    padding: 6px 0;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-secondary);
}

.nav-item.active {
    color: var(--primary);
}

.nav-icon {
    font-size: 22px;
    margin-bottom: 2px;
}

.nav-label {
    font-size: 10px;
    font-weight: 600;
}

/* ========== 弹窗 ========== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

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

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
}

.close-btn {
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
}

.modal-body {
    padding: 16px;
}

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

.add-option-group {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.add-option-group input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.add-btn {
    padding: 10px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.option-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg);
    border-radius: 8px;
}

.option-item span {
    font-size: 14px;
    font-weight: 600;
}

.option-item button {
    padding: 6px 12px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
}

.modal-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.modal-btn:first-child {
    background: var(--primary);
    color: white;
}

.modal-btn.danger {
    background: var(--danger);
    color: white;
}

.modal-btn.secondary {
    background: var(--text-secondary);
    color: white;
}

/* ========== 通知 ========== */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    left: 20px;
    padding: 14px 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    font-weight: 600;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-100px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ========== 适配桌面端 ========== */
@media (min-width: 768px) {
    body {
        padding: 20px;
    }

    .app-container {
        max-width: 1000px;
        margin: 0 auto;
        border-radius: 20px;
        overflow: hidden;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    }

    /* 桌面端顶部导航 */
    .desktop-nav {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        padding: 20px 30px;
        background: white;
        border-bottom: 1px solid var(--border);
    }

    .desktop-logo {
        font-size: 24px;
        font-weight: 700;
        margin: 0;
    }

    .desktop-tabs {
        display: flex;
        gap: 10px;
    }

    .desktop-tab {
        padding: 10px 20px;
        background: var(--bg);
        border-radius: 10px;
        cursor: pointer;
        transition: all 0.3s ease;
        font-weight: 600;
        font-size: 14px;
    }

    .desktop-tab:hover {
        background: var(--primary);
        color: white;
        transform: translateY(-2px);
    }

    .desktop-tab.active {
        background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
        color: white;
    }

    /* 隐藏底部导航 */
    .bottom-nav {
        display: none !important;
    }

    /* 页面容器 */
    .slider-container {
        background: var(--bg);
    }

    .page {
        padding: 30px;
        max-height: calc(100vh - 140px);
        overflow-y: auto;
        /* 在桌面端使用垂直布局，不滑动切换 */
        flex: 0 0 100% !important;
        scroll-snap-align: none !important;
    }

    .page-content {
        padding: 0;
        padding-bottom: 0;
        max-width: 900px;
        margin: 0 auto;
    }

    .page-title {
        font-size: 24px;
        margin-bottom: 20px;
        color: var(--text-primary);
    }

    .section-title {
        font-size: 18px;
        margin: 24px 0 16px 0;
        color: var(--text-primary);
    }

    .plan-header h4 {
        font-size: 16px;
        font-weight: 700;
        margin: 0;
    }

    /* 概览版面 */
    .overview-cards {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
        margin-bottom: 20px;
    }

    .overview-card {
        padding: 24px;
    }

    .card-icon {
        font-size: 36px;
        margin-bottom: 8px;
    }

    .card-label {
        font-size: 13px;
    }

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

    .progress-section {
        padding: 20px;
    }

    .progress-label {
        font-size: 15px;
    }

    .progress-bar {
        height: 16px;
    }

    /* 表单 */
    .form-group {
        margin-bottom: 16px;
    }

    .form-group label {
        font-size: 14px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 12px 16px;
        font-size: 15px;
    }

    .form-row-2 {
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }

    .toggle-group {
        gap: 12px;
    }

    .toggle-btn {
        padding: 10px;
        font-size: 14px;
    }

    .submit-btn {
        padding: 16px;
        font-size: 18px;
    }

    /* 计划版面 */
    .plan-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    .plan-card {
        padding: 20px;
    }

    .plan-header h3 {
        font-size: 18px;
    }

    /* 记录版面 */
    .search-bar {
        grid-template-columns: repeat(4, 1fr) auto auto;
        gap: 10px;
        margin-bottom: 20px;
    }

    .search-input {
        padding: 10px 14px;
        font-size: 14px;
    }

    .search-btn {
        padding: 10px 16px;
        font-size: 16px;
    }

    .records-list {
        min-height: 300px;
    }

    .record-item {
        padding: 16px;
        margin-bottom: 12px;
    }

    .record-title {
        font-size: 16px;
    }

    .record-date {
        font-size: 12px;
    }

    .record-body {
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
        font-size: 14px;
    }

    .data-operations {
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
    }

    .op-btn {
        padding: 14px;
        font-size: 15px;
    }

    /* 云同步版面 */
    .cloud-config {
        padding: 24px;
        margin-bottom: 20px;
    }

    .action-btn {
        padding: 16px;
        font-size: 15px;
        margin-bottom: 12px;
    }

    .cloud-info {
        padding: 16px;
        font-size: 14px;
    }

    /* 弹窗 */
    .modal-content {
        max-width: 500px;
    }
}
