/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

/* 容器样式 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 登录页面样式 */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

.login-box h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #333;
    font-size: 24px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #555;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s;
    width: 100%;
}

.btn:hover {
    background: #5a6fd8;
}

.btn:active {
    transform: translateY(1px);
}

.error-message {
    background: #fee;
    color: #d32f2f;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 20px;
    text-align: center;
    font-size: 14px;
}

.success-message {
    background: #e8f5e8;
    color: #388e3c;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 20px;
    text-align: center;
    font-size: 14px;
}

/* 头部样式 */
.header {
    background: #667eea;
    color: white;
    padding: 20px 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header h1 {
    font-size: 24px;
    font-weight: normal;
}

/* 导航样式 */
.nav {
    background: white;
    padding: 10px 0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.nav ul {
    list-style: none;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
}

.nav li {
    margin: 0 15px;
}

.nav a {
    color: #333;
    text-decoration: none;
    padding: 8px 15px;
    border-radius: 5px;
    transition: all 0.3s;
    display: block;
}

.nav a:hover {
    background: #667eea;
    color: white;
}

.nav a.active {
    background: #667eea;
    color: white;
}

/* 汉堡菜单样式 */
.hamburger-menu {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 50px;
    height: 50px;
    cursor: pointer;
    position: fixed;
    right: 10px;
    top: 25px;
    transform: translateY(0) translateZ(0);
    z-index: 99999;
    padding: 12px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    pointer-events: auto;
    will-change: transform, opacity;
    backface-visibility: hidden;
}

.hamburger-menu span {
    display: block;
    height: 3px;
    width: 100%;
    background: #333;
    border-radius: 3px;
    transition: all 0.3s ease;
    transform-origin: center;
}

.hamburger-menu:hover {
    background: #f5f7fa;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

/* 确保导航容器在移动设备上有足够的空间 */
@media (max-width: 768px) {
    .nav {
        padding-right: 60px;
    }
}

/* 汉堡菜单展开动画 */
.hamburger-menu.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger-menu.active span:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* 移动端导航样式 */
@media (max-width: 768px) {
    .nav {
        position: relative;
    }
    
    .hamburger-menu {
        display: flex;
    }
    
    .nav ul {
        flex-direction: column;
        align-items: center;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: white;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        z-index: 99999;
    }
    
    .nav ul.active {
        max-height: 400px;
        padding: 10px 0;
        z-index: 99999;
    }
    
    .nav li {
        margin: 5px 0;
        width: 100%;
        text-align: center;
    }
    
    .nav a {
        width: 100%;
    }
}

/* 主要内容区域 */
.main-content {
    padding: 20px 0;
}

/* 卡片样式 */
.card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 20px;
    margin-bottom: 20px;
}

.card h2 {
    font-size: 20px;
    margin-bottom: 20px;
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

/* 数据概览卡片 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    text-align: center;
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-card h3 {
    font-size: 16px;
    color: #666;
    margin-bottom: 10px;
}

.stat-card .amount {
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 5px;
}

.stat-card.income .amount {
    color: #388e3c;
}

.stat-card.expense .amount {
    color: #d32f2f;
}

.stat-card.balance .amount {
    color: #1976d2;
}

/* 按钮组样式 */
.btn-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.btn-large {
    padding: 20px;
    font-size: 18px;
    text-decoration: none;
    text-align: center;
    border-radius: 10px;
    transition: all 0.3s;
    display: block;
}

.btn-income {
    background: #e8f5e8;
    color: #388e3c;
    border: 2px solid #388e3c;
}

.btn-income:hover {
    background: #388e3c;
    color: white;
    transform: translateY(-3px);
}

.btn-expense {
    background: #ffebee;
    color: #d32f2f;
    border: 2px solid #d32f2f;
}

.btn-expense:hover {
    background: #d32f2f;
    color: white;
    transform: translateY(-3px);
}

/* 表单样式 */
.form-container {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    max-width: 600px;
    margin: 0 auto;
}

.form-container h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #333;
}

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

.form-row label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #555;
}

.form-row input[type="text"],
.form-row input[type="number"],
.form-row input[type="date"],
.form-row select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-row input:focus,
.form-row select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

/* 搜索建议下拉列表 */
.autocomplete-suggestions {
    position: absolute;
    background: white;
    border: 1px solid #ddd;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
    width: 100%;
    margin-top: 2px;
    box-sizing: border-box;
    left: 0;
    right: 0;
}

.autocomplete-suggestion {
    padding: 10px 15px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    border-bottom: 1px solid #f0f0f0;
}

.autocomplete-suggestion:last-child {
    border-bottom: none;
}

.autocomplete-suggestion:hover,
.autocomplete-suggestion.selected {
    background-color: #f5f7fa;
    color: #667eea;
}

/* 确保输入框容器相对定位 */
.form-row {
    position: relative;
}

/* 表格样式 */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

table th,
table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

table th {
    background: #f5f7fa;
    font-weight: bold;
    color: #333;
    position: sticky;
    top: 0;
}

table tr:hover {
    background: #f9f9f9;
}

/* 操作按钮样式 */
.action-buttons {
    display: flex;
    gap: 5px;
}

.btn-small {
    padding: 5px 10px;
    font-size: 12px;
    text-decoration: none;
    border-radius: 3px;
    transition: all 0.3s;
    display: inline-block;
}

.btn-edit {
    background: #1976d2;
    color: white;
}

.btn-edit:hover {
    background: #1565c0;
}

.btn-delete {
    background: #d32f2f;
    color: white;
}

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

.btn-add {
    background: #388e3c;
    color: white;
    margin-bottom: 20px;
    display: inline-block;
}

.btn-add:hover {
    background: #2e7d32;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .login-box {
        padding: 20px;
        margin: 20px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .form-container {
        padding: 20px;
        margin: 20px;
    }
    
    .btn-group {
        grid-template-columns: 1fr;
    }
    
    table {
        font-size: 14px;
    }
    
    table th,
    table td {
        padding: 8px;
    }
    
    .action-buttons {
        flex-direction: column;
    }
}

/* 加载状态 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 模态框样式 */
.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.5);
}

.modal-content {
    background-color: white;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 90%;
    max-width: 500px;
    border-radius: 10px;
    position: relative;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    right: 20px;
    top: 10px;
    cursor: pointer;
}

.close:hover {
    color: black;
}

/* 选择器容器 */
.selector-container {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.selector-container > div {
    flex: 1;
    min-width: 200px;
}

.selector-container select,
.selector-container input,
.form-row.flex-row select,
.form-row.flex-row input {
    width: 100%;
    max-width: 100%;
    padding: 12px 15px;
    font-size: 16px;
    border: 1px solid #ddd;
    border-radius: 5px;
    box-sizing: border-box;
    transition: all 0.3s ease;
    height: 45px;
}

.selector-container select:focus,
.selector-container input:focus,
.form-row.flex-row select:focus,
.form-row.flex-row input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

/* 表单按钮样式调整 */
.form-row button,
.selector-container button {
    padding: 8px 15px;
    font-size: 14px;
    white-space: nowrap;
    min-width: auto;
    height: 45px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* 表单标签样式调整 */
.selector-container label,
.form-row.flex-row label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

/* 响应式优化 */
@media (max-width: 768px) {
    .selector-container {
        flex-direction: column;
    }
    
    .selector-container > div,
    .form-row.flex-row > div {
        width: 100%;
        min-width: auto;
    }
    
    .selector-container button,
    .form-row.flex-row button {
        width: 100%;
        margin-top: 5px;
    }
    
    .selector-container select,
    .selector-container input,
    .form-row.flex-row select,
    .form-row.flex-row input,
    .selector-container button,
    .form-row.flex-row button {
        height: 42px;
        font-size: 14px;
    }
}

/* 表单行样式调整 */
.form-row.flex-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-row.flex-row > div {
    flex: 1;
    min-width: 200px;
}

.form-row.flex-row button {
    margin-bottom: 0;
}

/* 数字输入框加减按钮 */
.number-input-container {
    display: flex;
    align-items: center;
}

.number-input {
    flex: 1;
    text-align: center;
}

.number-btn {
    background: #f5f7fa;
    border: 1px solid #ddd;
    color: #333;
    padding: 12px;
    cursor: pointer;
    transition: all 0.3s;
    width: 50px;
}

.number-btn:hover {
    background: #e0e0e0;
}

.number-btn:first-child {
    border-radius: 5px 0 0 5px;
}

.number-btn:last-child {
    border-radius: 0 5px 5px 0;
}

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

.pagination .btn-small {
    margin: 0;
}

.pagination .current-page {
    font-size: 14px;
    color: #666;
    margin: 0 15px;
}

.pagination .btn-small.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.pagination .btn-small.disabled:hover {
    background-color: inherit;
    color: inherit;
}

/* 收支明细页面搜索容器样式 */
.search-container {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    align-items: flex-end;
}

.search-container > div {
    flex: 1;
    min-width: 200px;
}

.search-container input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.search-container input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.search-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.search-btn:hover {
    background: #5a6fd8;
}

@media (max-width: 768px) {
    .search-container {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .search-container > div {
        min-width: auto;
    }
}

/* 统计分析页面样式 */
.chart-container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

canvas {
    width: 100%;
    height: auto;
}

.stats-table {
    margin: 20px 0;
}

.stats-table table {
    width: 100%;
    border-collapse: collapse;
}

.stats-table th,
.stats-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.stats-table th {
    background: #f5f7fa;
    font-weight: bold;
}

.stats-section {
    margin-bottom: 30px;
}

.stats-section h3 {
    margin-bottom: 15px;
    color: #333;
}