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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

.container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* 登录面板 */
.login-card {
    background: white;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
}

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

.login-card h2 i {
    margin-right: 10px;
    color: #667eea;
}

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

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

.input-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.input-group input:focus {
    outline: none;
    border-color: #667eea;
}

.error-message {
    background: #fee;
    color: #c00;
    padding: 12px;
    border-radius: 8px;
    border-left: 4px solid #c00;
    margin-bottom: 20px;
    display: none;
}

.error-message.show {
    display: block;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.btn-primary, .btn-secondary {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: #4f46e5;
    color: white;
}

.btn-primary:hover {
    background: #4338ca;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
    transform: translateY(-2px);
}

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

.tip {
    text-align: center;
    color: #6b7280;
    font-size: 14px;
    margin-top: 20px;
}

/* 主应用 */
.hidden {
    display: none !important;
}

#mainApp {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 头部 */
.header {
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    border-bottom: 1px solid #e5e7eb;
}

.header-left h1 {
    font-size: 24px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-left h1 i {
    color: #4f46e5;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 20px;
    color: #6b7280;
}

.btn-logout {
    background: #ef4444;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.3s;
}

.btn-logout:hover {
    background: #dc2626;
}

/* 标签页 */
.tabs {
    display: flex;
    padding: 0 40px;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    overflow-x: auto;
}

.tab {
    padding: 16px 24px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 16px;
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
    white-space: nowrap;
}

.tab:hover {
    color: #4f46e5;
    background: #f8fafc;
}

.tab.active {
    color: #4f46e5;
    border-bottom-color: #4f46e5;
    font-weight: 500;
}

/* 内容区域 */
.content {
    flex: 1;
    padding: 40px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.content-section {
    display: none;
}

.content-section.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 仪表盘 */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.time-filter {
    display: flex;
    gap: 10px;
}

.time-filter select {
    padding: 8px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    border-top: 4px solid;
}

.income-card {
    border-top-color: #10b981;
}

.expense-card {
    border-top-color: #ef4444;
}

.balance-card {
    border-top-color: #3b82f6;
}

.card h3 {
    font-size: 16px;
    color: #6b7280;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.amount {
    font-size: 32px;
    font-weight: bold;
    color: #1f2937;
}

.income-card .amount {
    color: #10b981;
}

.expense-card .amount {
    color: #ef4444;
}

.balance-card .amount {
    color: #3b82f6;
}

.dashboard-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

.chart-container {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.chart-container h3 {
    font-size: 18px;
    margin-bottom: 20px;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-container canvas {
    width: 100% !important;
    height: 300px !important;
}

.recent-transactions {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.recent-transactions h3 {
    font-size: 18px;
    margin-bottom: 20px;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 8px;
}

.transaction-list {
    max-height: 300px;
    overflow-y: auto;
}

.empty-message {
    text-align: center;
    padding: 40px;
    color: #9ca3af;
    font-style: italic;
}

/* 交易列表样式 */
.transaction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #e5e7eb;
    transition: background 0.3s;
}

.transaction-item:hover {
    background: #f9fafb;
}

.transaction-item:last-child {
    border-bottom: none;
}

.transaction-info {
    flex: 1;
}

.transaction-date {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 4px;
}

.transaction-counterparty {
    font-weight: 500;
    color: #374151;
    margin-bottom: 4px;
}

.transaction-category {
    font-size: 12px;
    color: #9ca3af;
    background: #f3f4f6;
    padding: 2px 8px;
    border-radius: 12px;
    display: inline-block;
}

.transaction-amount {
    font-weight: bold;
    font-size: 18px;
}

.transaction-amount.income {
    color: #10b981;
}

.transaction-amount.expense {
    color: #ef4444;
}

/* 表格样式 */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 20px;
}

.section-header h2 {
    font-size: 24px;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 10px;
}

.filters {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.filters select,
.filters input {
    padding: 8px 12px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    font-size: 14px;
    min-width: 120px;
}

.filters input {
    min-width: 200px;
}

.table-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    overflow: hidden;
    margin-bottom: 20px;
}

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

th {
    background: #f9fafb;
    padding: 16px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #e5e7eb;
}

td {
    padding: 16px;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: middle;
}

tbody tr:hover {
    background: #f9fafb;
}

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-income {
    background: #d1fae5;
    color: #065f46;
}

.badge-expense {
    background: #fee2e2;
    color: #991b1b;
}

.table-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    padding: 6px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 6px;
    color: #6b7280;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-edit:hover {
    background: #dbeafe;
    color: #3b82f6;
}

.btn-delete:hover {
    background: #fee2e2;
    color: #ef4444;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 30px;
}

#pageInfo {
    color: #6b7280;
    font-size: 14px;
}

/* 快速记账表单 */
.quick-form {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

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

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #4f46e5;
}

.radio-group {
    display: flex;
    gap: 20px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 16px;
    color: #374151;
}

.radio-custom {
    width: 20px;
    height: 20px;
    border: 2px solid #d1d5db;
    border-radius: 50%;
    position: relative;
    transition: all 0.3s;
}

.radio-custom::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: white;
    transition: all 0.3s;
}

.radio-label input:checked + .radio-custom.expense {
    background: #ef4444;
    border-color: #ef4444;
}

.radio-label input:checked + .radio-custom.income {
    background: #10b981;
    border-color: #10b981;
}

.radio-label input:checked + .radio-custom::after {
    background: white;
}

.radio-label input {
    display: none;
}

.today-records {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #e5e7eb;
}

.history-item:last-child {
    border-bottom: none;
}

/* 预算管理 */
.budget-controls {
    margin-bottom: 30px;
}

.budget-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.budget-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    text-align: center;
}

.budget-card h3 {
    font-size: 16px;
    color: #6b7280;
    margin-bottom: 12px;
}

.budget-list {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.budget-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid #e5e7eb;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    margin: 0 20px;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}

.progress-safe {
    background: #10b981;
}

.progress-warning {
    background: #f59e0b;
}

.progress-danger {
    background: #ef4444;
}

.percentage {
    font-weight: bold;
    min-width: 60px;
    text-align: right;
}

.percentage.safe {
    color: #10b981;
}

.percentage.warning {
    color: #f59e0b;
}

.percentage.danger {
    color: #ef4444;
}

.add-budget {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* 飞书设置 */
.feishu-guide,
.feishu-webhook,
.feishu-usage {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.code-block {
    background: #f3f4f6;
    padding: 16px;
    border-radius: 8px;
    margin: 16px 0;
    font-family: 'Monaco', 'Menlo', monospace;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.code-block code {
    flex: 1;
    word-break: break-all;
    color: #374151;
}

.example {
    background: #f8fafc;
    padding: 20px;
    border-radius: 8px;
    margin-top: 16px;
}

.example ul {
    list-style: none;
    margin-top: 10px;
}

.example li {
    padding: 8px 0;
    color: #6b7280;
}

.example code {
    background: #e5e7eb;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', monospace;
    color: #1f2937;
}

.status-message {
    padding: 12px;
    border-radius: 8px;
    margin-top: 16px;
    display: none;
}

.status-message.success {
    background: #d1fae5;
    color: #065f46;
    border-left: 4px solid #10b981;
    display: block;
}

.status-message.error {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid #ef4444;
    display: block;
}

/* 模态框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h3 {
    font-size: 20px;
    margin-bottom: 24px;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #10b981;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 1001;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* 加载动画 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1002;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e5e7eb;
    border-top-color: #4f46e5;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .dashboard-charts {
        grid-template-columns: 1fr;
    }
    
    .chart-container canvas {
        height: 250px !important;
    }
    
    .header-left {
        padding: 20px;
        flex-direction: column;
        gap: 20px;
        align-items: stretch;
    }
    
    .user-info {
        justify-content: space-between;
    }
    
    .content {
        padding: 20px;
    }
    
    .tabs {
        padding: 0 20px;
    }
    
    .tab {
        padding: 12px 16px;
        font-size: 14px;
    }
    
    .section-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filters {
        flex-direction: column;
    }
    
    .filters select,
    .filters input {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .login-card {
        padding: 30px 20px;
    }
    
    .dashboard-cards {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .button-group {
        flex-direction: column;
    }
}