/* 基础样式 */
body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    color: #333;
    font-size: 16px;
}

/* 移动优先断点 */
@media (min-width: 481px) {
    body {
        font-size: 18px;
    }
}

header {
    background: #2c3e50;
    color: white;
    padding: 1rem;
    text-align: center;
    position: relative;
}

/* 导航菜单 - 移动端 */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
}

nav {
    background: #34495e;
    padding: 0.5rem;
}

nav a {
    color: white;
    text-decoration: none;
    margin: 0 1rem;
    padding: 0.5rem;
    display: inline-block;
}

nav a:hover {
    text-decoration: underline;
}

/* 响应式导航 */
@media (max-width: 768px) {
    .menu-toggle {
        display: block;
        position: absolute;
        top: 1rem;
        right: 1rem;
    }
    
    nav {
        display: none;
        padding: 1rem 0;
    }
    
    nav.active {
        display: block;
    }
    
    nav a {
        display: block;
        margin: 0;
        padding: 0.75rem 1rem;
    }
}

main {
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

footer {
    text-align: center;
    padding: 1rem;
    background: #ecf0f1;
    margin-top: 2rem;
}

/* 表格样式 */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1rem 0;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #eee;
    border-radius: 5px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

@media (max-width: 600px) {
    .table-container {
        margin: 1rem -1rem;
        border-left: none;
        border-right: none;
        border-radius: 0;
    }
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

th {
    background-color: #f2f2f2;
}

tr:hover {
    background-color: #f5f5f5;
}

@media (max-width: 480px) {
    th, td {
        padding: 0.5rem;
        font-size: 0.9rem;
    }
    
    .btn {
        font-size: 0.9rem;
        padding: 0.5rem;
    }
    
    .filter-form .form-group {
        margin-bottom: 0.75rem;
    }
    
    .filter-form input {
        font-size: 0.9rem;
        padding: 0.5rem;
    }

    .form-group.horizontal {
        flex-direction: column;
        gap: 0.25rem;
    }
}

/* 表单样式 */
form {
    max-width: 600px;
    margin: 1rem auto;
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: 5px;
}

.form-group {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.form-group.horizontal {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}

.form-group.horizontal label {
    margin-bottom: 0;
    min-width: 120px;
}

input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    max-width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    box-sizing: border-box;
}

@media (max-width: 480px) {
    input[type="text"],
    input[type="number"],
    input[type="date"],
    select,
    textarea {
        padding: 0.5rem;
    }
}

button, .btn, a.btn {
    background: #0080ff;
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    min-width: 48px;
    min-height: 48px;
    display: inline-block;
    text-align: center;
    text-decoration: none;
    box-sizing: border-box;
    line-height: 1.5;
}

button:hover, .btn:hover {
    background: #ff0000;
}

@media (max-width: 480px) {
    form {
        padding: 0.75rem;
        margin: 0 -1rem;
        border-left: none;
        border-right: none;
        border-radius: 0;
    }
    
    .form-group {
        margin-bottom: 1rem;
    }
    
    button, .btn {
        padding: 0.6rem 1rem;
        margin-bottom: 0.5rem;
        display: block;
        width: 100%;
    }
    
    .stats-container {
        margin: 1rem -1rem;
    }
    
    .stat-block {
        padding: 0.75rem;
        border-left: none;
        border-right: none;
        border-radius: 0;
    }

    /* 分页响应式样式 */
    .pagination {
        flex-wrap: wrap;
        gap: 5px;
        justify-content: center;
    }
    
    .pagination a, 
    .pagination span {
        padding: 5px 8px;
        font-size: 0.9rem;
    }
    
    /* 表格操作按钮 */
    table td:last-child {
        white-space: nowrap;
    }
    
    table td:last-child .btn {
        display: inline-block;
        width: auto;
        margin-right: 5px;
        margin-bottom: 0;
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }
    
    /* 筛选表单按钮 */
    .filter-form .btn {
        width: auto;
        display: inline-block;
        margin-right: 5px;
    }
}

/* 最近记录 */
.recent-records {
    margin: 2rem 0;
}

.recent-records h2 {
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

@media (max-width: 768px) {
    .recent-records h2 {
        font-size: 1.3rem;
    }
}

/* 摘要卡片 */
.summary {
    display: flex;
    justify-content: space-between;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.summary-card {
    flex: 1;
    padding: 1rem;
    margin: 0 0.5rem 1rem;
    border-radius: 5px;
    text-align: center;
    color: white;
    min-width: 200px;
}

@media (max-width: 768px) {
    .summary {
        flex-direction: column;
    }
    
    .summary-card {
        margin: 0 0 1rem;
        width: 100%;
    }
    
    .summary-card p {
        font-size: 1.2rem;
    }
}

.summary-card.income {
    background: #2ecc71;
}

.summary-card.expense {
    background: #e74c3c;
}

.summary-card.balance {
    background: #3498db;
}

.summary-card h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
}

.summary-card p {
    font-size: 1.5rem;
    font-weight: bold;
    margin: 0;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}


/* 闪存消息 */
.flash {
    padding: 0.75rem;
    margin-bottom: 1rem;
    border-radius: 4px;
}

.flash.success {
    background: #d4edda;
    color: #155724;
}

.flash.error {
    background: #f8d7da;
    color: #721c24;
}

/* 删除链接 */
.delete {
    color: #fa0000;
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
}

.modal-content {
    background-color: #fefefe;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 90%;
    max-width: 500px;
    border-radius: 5px;
    position: relative;
}

.close {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: black;
}

#saveCategory {
    background: #0080ff;
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    min-width: 48px;
    min-height: 48px;
}

#saveCategory:hover {
    background: #0066cc;
}

@media (max-width: 768px) {
    .modal-content {
        margin: 20% auto;
        padding: 15px;
    }
    
    .close {
        top: 5px;
        right: 10px;
        font-size: 24px;
    }
}

@media (max-width: 480px) {
    .modal-content {
        margin: 30% auto;
        width: 95%;
        padding: 10px;
    }
    
    #saveCategory {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
}


/* 图表容器 */
canvas {
    margin: 1rem 0;
    max-width: 100%;
}

/* 统计区块样式 */
.stats-container {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    margin: 2rem auto;
    max-width: 1200px;
}

.stat-block {
    flex: 1;
    min-width: 400px;
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

@media (max-width: 900px) {
    .stat-block {
        min-width: 100%;
    }
}

/* 分类管理样式 */
.category-management {
    margin: 2rem 0;
}

.category-types {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.category-type {
    flex: 1;
    min-width: 300px;
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: white;
}

.category-type.income {
    border-top: 4px solid #2ecc71;
}

.category-type.expense {
    border-top: 4px solid #e74c3c;
}

.category-type h3 {
    margin-top: 0;
    color: #2c3e50;
}

.category-type ul {
    list-style: none;
    padding-left: 0;
}

.category-type li {
    padding: 0.5rem 0;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.category-type li > span {
    flex-grow: 1;
}

.category-type li .actions {
    margin-left: 1rem;
    flex-shrink: 0;
}

.category-type li ul {
    padding-left: 1.5rem;
    margin-top: 0.5rem;
}

.category-type li ul li {
    border-bottom: none;
    padding: 0.3rem 0;
}

.actions {
    display: inline-block;
    margin-left: 1rem;
}

.actions a {
    font-size: 0.9rem;
    padding: 0.2rem 0.5rem;
    margin-right: 0.5rem;
    border-radius: 3px;
    text-decoration: none;
}

.actions .edit {
    background: #3498db;
    color: white;
}

.actions .delete {
    background: #e74c3c;
    color: white;
}

.actions .add {
    background: #2ecc71;
    color: white;
}

.actions a:hover {
    opacity: 0.8;
}

@media (max-width: 768px) {
    .category-types {
        flex-direction: column;
    }
    
    .category-type {
        min-width: 100%;
    }
}
