* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

:root {
    --primary: #4361ee;
    --secondary: #3f37c9;
    --success: #4cc9f0;
    --danger: #f72585;
    --light: #f8f9fa;
    --dark: #212529;
    --shadow: 0 4px 6px rgba(0,0,0,0.1);
}

body {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    padding: 0; /* 移除body的内边距 */
    color: var(--dark);
}

.container {
    max-width: 100%; /* 移除最大宽度限制 */
    margin: 20px auto;
    padding: 30px;
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

h1 {
    color: var(--primary);
    margin-bottom: 30px;
    font-weight: 700;
    text-align: center;
    font-size: 2.5rem;
    position: relative;
    padding-bottom: 15px;
}

h1::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: var(--success);
    border-radius: 2px;
}

.filter-controls {
    margin-bottom: 30px;
}

.filter-row {
    display: flex;
    gap: 10px; /* 调整为10px，与现有样式保持一致 */
    align-items: center; /* 垂直居中对齐所有元素 */
    flex-wrap: wrap; /* 允许换行，以便在小屏幕上堆叠 */
}

.filter-group {
    flex: 1; /* 让筛选组平均分配空间 */
    min-width: 150px; /* 最小宽度 */
}

.filter-controls button {
    flex-shrink: 0; /* 防止按钮缩小 */
    width: auto; /* 覆盖全局按钮样式 */
    padding: 12px 20px; /* 调整按钮内边距 */
    font-size: 15px; /* 调整按钮字体大小 */
}

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

.form-row {
    display: flex;
    gap: 10px; /* 调整元素之间的间距 */
    margin-bottom: 20px;
    align-items: flex-end; /* 底部对齐 */
}

.form-row .form-group {
    margin-bottom: 0; /* 移除底部 form-group 的底部外边距 */
}

.form-row .amount-group {
    flex: 2; /* 金额输入框占据更多空间 */
}

.form-row .type-group {
    flex: 1; /* 类型选择框占据较少空间 */
}

.form-row {
    display: flex;
    gap: 10px; /* 调整元素之间的间距 */
    margin-bottom: 20px;
    align-items: flex-end; /* 底部对齐 */
}

.form-row .form-group {
    margin-bottom: 0; /* 移除内部 form-group 的底部外边距 */
}

.form-row .amount-group {
    flex: 2; /* 金额输入框占据更多空间 */
}

.form-row .type-group {
    flex: 1; /* 类型选择框占据较少空间 */
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--secondary);
}

/* 筛选框内label的特定样式 */
.filter-row label {
    flex: 0 0 calc((100% - (5 * 10px)) * 0.05); /* 5% */
    margin-bottom: 0; /* 移除底部外边距 */
    text-align: right; /* 文本右对齐 */
    padding-right: 5px; /* 增加一点间距 */
}

/* 筛选框内input和type="date"和select的特定样式 */
.filter-row input[type="date"],
.filter-row select {
    flex: 0 0 calc((100% - (5 * 10px)) * 0.3); /* 30% */
}

/* 筛选框内button的特定样式 */
.filter-row button {
    flex: 0 0 calc((100% - (5 * 10px)) * 0.15); /* 15% */
    margin-top: 0; /* 移除顶部外边距 */
}

input[type="number"],
input[type="text"],
input[type="date"] {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s ease;
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
    outline: none;
}

button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    width: 100%;
    transition: all 0.3s ease;
    letter-spacing: 1px;
}

button:hover {
    background: var(--secondary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.records {
    margin-top: 40px;
    background: var(--light);
    border-radius: 12px;
    padding: 20px;
}

.summary {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: var(--shadow);
}

.summary h2 {
    color: var(--primary);
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.summary-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.summary-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

.summary-item span {
    display: block;
}

.summary-item span:first-child {
    color: var(--secondary);
    font-weight: 600;
    margin-bottom: 8px;
}

.summary-item.total {
    background: var(--primary);
    color: white;
}

.summary-item.total span {
    color: white;
}

h2 {
    color: var(--secondary);
    margin-bottom: 20px;
    font-size: 1.8rem;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 10px;
}

th {
    background: var(--primary);
    color: white;
    padding: 15px;
    text-align: left;
    font-weight: 600;
}

th:first-child {
    border-radius: 8px 0 0 8px;
}

th:last-child {
    border-radius: 0 8px 8px 0;
}

/* 新增类型选择框样式 */
select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 16px;
    background: white;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
    transition: all 0.3s ease;
}

select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
    outline: none;
}

/* 调整表格列宽 */
th:nth-child(1) { width: 20%; }
th:nth-child(2) { width: 15%; }
th:nth-child(3) { width: 15%; }
th:nth-child(4) { width: 35%; }
th:nth-child(5) { width: 15%; }

td {
    padding: 15px;
    background: white;
    border-bottom: 2px solid var(--light);
}

tr {
    transition: all 0.3s ease;
}

tr:hover {
    transform: translateX(5px);
}

.delete-btn {
    background: var(--danger);
    padding: 8px 15px;
    font-size: 14px;
    width: auto;
    border-radius: 6px;
}

.delete-btn:hover {
    background: #d1146a;
}

.empty-state {
    text-align: center;
    padding: 30px;
    color: #6c757d;
    font-style: italic;
}

/* 分页样式 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
    gap: 10px;
}

.pagination button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    width: auto; /* 覆盖全局按钮样式 */
}

.pagination button:disabled {
    background: #cccccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.pagination button:hover:not(:disabled) {
    background: var(--secondary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
    .filter-row {
        gap: 10px;
    }

#pageInfo {
    font-size: 1rem;
    color: var(--dark);
    font-weight: 600;
    min-width: 100px; /* 确保页码信息有足够的宽度 */
    text-align: center;
}

/* 动画效果 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.container {
    animation: fadeIn 0.6s ease-out;
}

/* 手机端适配 */
@media (max-width: 768px) {
    .container {
        padding: 10px; /* 减少内边距 */
        margin: 0; /* 手机端填满屏幕宽度，移除左右外边距 */
    }
    
    h1 {
        font-size: 1.8rem; /* 调整字体大小 */
        margin-bottom: 15px; /* 减少外边距 */
    }

    h2 {
        font-size: 1.3rem; /* 调整字体大小 */
        margin-bottom: 10px; /* 减少外边距 */
    }

    .summary {
        padding: 15px; /* 调整汇总区域内边距 */
        margin-bottom: 15px; /* 调整汇总区域外边距 */
    }

    .summary h2 {
        font-size: 1.3rem; /* 调整汇总标题字体大小 */
        margin-bottom: 10px;
    }

    .summary-content {
        grid-template-columns: 1fr; /* 小屏幕下改为单列 */
        gap: 10px; /* 调整间距 */
    }

    .summary-item {
        padding: 10px; /* 调整汇总项内边距 */
        font-size: 0.9rem; /* 调整字体大小 */
    }

    .summary-item span:first-child {
        margin-bottom: 5px;
    }

    .form-group {
        margin-bottom: 10px; /* 减少表单组外边距 */
    }

    label {
        font-size: 0.85rem; /* 调整字体大小 */
        margin-bottom: 3px; /* 减少外边距 */
    }

    input[type="number"],
    input[type="text"],
    select {
        padding: 8px 10px; /* 调整内边距 */
        font-size: 13px; /* 调整字体大小 */
    }
    
    button {
        padding: 10px; /* 调整按钮内边距 */
        font-size: 14px; /* 调整按钮字体大小 */
    }

    .form-row {
        flex-direction: column; /* 手机端改为垂直堆叠 */
        gap: 15px;
        align-items: stretch; /* 元素拉伸填充宽度 */
    }

    /* 手机端筛选框样式调整 */
    .filter-row {
        flex-direction: column; /* 手机端垂直堆叠 */
        align-items: stretch; /* 元素拉伸填充宽度 */
        gap: 10px; /* 调整间距 */
    }

    .filter-row label {
        flex: unset; /* 移除flex属性 */
        width: auto; /* 恢复自动宽度 */
        text-align: left; /* 文本左对齐 */
        padding-right: 0; /* 移除右内边距 */
        margin-bottom: 5px; /* 增加底部外边距 */
    }

    .filter-row input[type="date"],
    .filter-row select,
    .filter-row button {
        flex: unset; /* 移除flex属性 */
        width: 100%; /* 占据整行 */
        margin-top: 0; /* 移除顶部外边距 */
    }
    
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap; /* 防止内容换行 */
    }
    
    th, td {
        padding: 8px; /* 调整表格单元格内边距 */
        font-size: 12px; /* 调整表格字体大小 */
        min-width: 70px; /* 确保列有最小宽度 */
    }

    th:nth-child(1) { width: 25%; } /* 日期 */
    th:nth-child(2) { width: 20%; } /* 金额 */
    th:nth-child(3) { width: 15%; } /* 类型 */
    th:nth-child(4) { width: 25%; } /* 备注 */
    th:nth-child(5) { width: 15%; } /* 操作 */

    .delete-btn {
        padding: 5px 8px; /* 调整删除按钮内边距 */
        font-size: 11px; /* 调整删除按钮字体大小 */
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.6rem;
    }

    h2 {
        font-size: 1.2rem;
    }

    .summary-item {
        font-size: 0.8rem;
    }

    th, td {
        padding: 6px;
        font-size: 11px;
        min-width: 60px;
    }

    .delete-btn {
        padding: 4px 6px;
        font-size: 10px;
    }

    .form-row {
        gap: 10px; /* 进一步调整间距 */
    }
}