:root {
    --primary-color: #165DFF;
    --primary-light: #E8F3FF;
    --primary-gradient: linear-gradient(135deg, #165DFF 0%, #4080FF 100%);
    --text-primary: #1D2129;
    --text-secondary: #4E5969;
    --text-tertiary: #86909C;
    --border-color: #E5E6EB;
    --background-color: #F2F3F5;
    --card-background: #FFFFFF;
    --success-color: #00B42A;
    --expense-color: #F53F3F;
    --income-color: #51CF66;
    --warning-color: #FF9800;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(22, 93, 255, 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--background-color);
    min-height: 100vh;
    padding-bottom: 100px;
}

.container {
    max-width: 750px;
    margin: 0 auto;
    background: white;
    min-height: 100vh;
    position: relative;
}

.header {
    background: var(--primary-gradient);
    color: white;
    padding: 16px;
    padding-top: calc(16px + env(safe-area-inset-top));
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.header-title {
    font-size: 18px;
    font-weight: 600;
}

.header-btn {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.header-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.stats-summary {
    display: flex;
    gap: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    padding: 12px;
}

.stat-item {
    flex: 1;
    text-align: center;
}

.stat-label {
    font-size: 12px;
    opacity: 0.8;
    margin-bottom: 4px;
    display: block;
}

.stat-value {
    font-size: 16px;
    font-weight: 600;
}

.stat-value.expense {
    color: #FF6B6B;
}

.stat-value.income {
    color: #51CF66;
}

.stat-value.balance {
    color: white;
}

.stat-value.negative {
    color: #FF6B6B;
}

.month-selector {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background-color: var(--card-background);
    border-bottom: 1px solid var(--border-color);
}

.month-btn {
    width: 32px;
    height: 32px;
    background: var(--background-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.2s;
}

.month-btn:hover {
    background: var(--primary-light);
    color: var(--primary-color);
}

.current-month {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 80px;
    text-align: center;
}

.record-list {
    height: calc(100vh - 300px);
    padding: 8px;
    overflow-y: auto;
}

.date-group {
    margin-bottom: 12px;
}

.date-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.date-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

.date-summary {
    font-size: 12px;
    color: var(--text-tertiary);
}

.date-summary .expense {
    color: var(--expense-color);
    margin-right: 8px;
}

.date-summary .income {
    color: var(--income-color);
}

.record-item {
    display: flex;
    align-items: center;
    padding: 12px;
    background-color: var(--card-background);
    border-radius: var(--radius-lg);
    margin-bottom: 6px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: box-shadow 0.2s;
}

.record-item:hover {
    box-shadow: var(--shadow-md);
}

.record-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-right: 12px;
}

.record-info {
    flex: 1;
}

.record-category {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
    display: block;
}

.record-remark {
    font-size: 12px;
    color: var(--text-tertiary);
}

.record-amount {
    font-size: 16px;
    font-weight: 600;
}

.record-amount.expense {
    color: var(--expense-color);
}

.record-amount.income {
    color: var(--income-color);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-tertiary);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    display: block;
}

.empty-text {
    font-size: 14px;
}

.fab {
    position: fixed;
    right: 20px;
    bottom: 100px;
    width: 56px;
    height: 56px;
    background: var(--primary-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    cursor: pointer;
    transition: transform 0.2s;
}

.fab:hover {
    transform: scale(1.1);
}

.fab-icon {
    font-size: 24px;
    color: white;
    font-weight: 300;
}

.detail-popup {
    width: 300px;
    background-color: var(--card-background);
    border-radius: var(--radius-xl);
    padding: 20px;
}

.popup-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: block;
    text-align: center;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.detail-label {
    font-size: 14px;
    color: var(--text-tertiary);
}

.detail-value {
    font-size: 14px;
    color: var(--text-primary);
}

.detail-value.expense {
    color: var(--expense-color);
}

.detail-value.income {
    color: var(--income-color);
}

.popup-buttons {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.btn-edit, .btn-delete, .btn-close {
    flex: 1;
    height: 40px;
    border-radius: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-edit:hover, .btn-delete:hover, .btn-close:hover {
    opacity: 0.8;
}

.btn-edit {
    background-color: var(--primary-color);
    color: white;
}

.btn-delete {
    background-color: var(--expense-color);
    color: white;
}

.btn-close {
    background-color: var(--background-color);
    color: var(--text-secondary);
}

.overview-card {
    background-color: var(--card-background);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
}

.overview-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.overview-divider {
    width: 1px;
    height: 30px;
    background-color: var(--border-color);
}

.overview-label {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 6px;
}

.overview-value {
    font-size: 16px;
    font-weight: 600;
}

.chart-section, .trend-section {
    background-color: var(--card-background);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 12px;
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: block;
}

.pie-chart {
    display: flex;
    flex-direction: column;
}

.pie-placeholder {
    height: 100px;
    background-color: var(--background-color);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    font-size: 12px;
    margin-bottom: 12px;
}

.legend-list {
    display: flex;
    flex-direction: column;
}

.legend-item {
    display: flex;
    align-items: center;
    padding: 6px 0;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    margin-right: 6px;
}

.legend-name {
    flex: 1;
    font-size: 13px;
    color: var(--text-secondary);
}

.legend-value {
    font-size: 13px;
    color: var(--text-primary);
    margin-right: 6px;
}

.legend-percent {
    font-size: 12px;
    color: var(--text-tertiary);
    width: 40px;
    text-align: right;
}

.trend-chart {
    height: 100px;
}

.chart-bars {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 100%;
    padding-top: 20px;
}

.chart-bar-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.bar-wrapper {
    display: flex;
    align-items: flex-end;
    height: 70px;
    gap: 2px;
}

.bar {
    width: 12px;
    border-radius: 2px 2px 0 0;
}

.bar.income {
    background-color: var(--income-color);
}

.bar.expense {
    background-color: var(--expense-color);
}

.bar-label {
    font-size: 10px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.form-container {
    padding: 16px;
}

.form-item {
    background-color: var(--card-background);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 12px;
}

.form-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    display: block;
}

.form-input {
    width: 100%;
    height: 44px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0 12px;
    font-size: 16px;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus {
    border-color: var(--primary-color);
}

.form-picker {
    height: 44px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: border-color 0.2s;
}

.form-picker:hover {
    border-color: var(--primary-color);
}

.form-picker-text {
    font-size: 16px;
    color: var(--text-primary);
}

.form-picker-arrow {
    color: var(--text-tertiary);
}

.form-switch {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.form-switch-text {
    font-size: 14px;
    color: var(--text-secondary);
}

.switch {
    width: 44px;
    height: 24px;
    background-color: var(--border-color);
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    transition: background-color 0.2s;
}

.switch.active {
    background-color: var(--primary-color);
}

.switch::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background-color: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.2s;
}

.switch.active::after {
    transform: translateX(20px);
}

.form-textarea {
    width: 100%;
    height: 80px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    font-size: 16px;
    color: var(--text-primary);
    outline: none;
    resize: none;
    transition: border-color 0.2s;
}

.form-textarea:focus {
    border-color: var(--primary-color);
}

.submit-btn {
    width: 100%;
    height: 48px;
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.submit-btn:hover {
    opacity: 0.9;
}

.submit-btn:active {
    opacity: 0.8;
}

@media screen and (min-width: 768px) {
    .container {
        box-shadow: var(--shadow-md);
        border-radius: 0 0 var(--radius-xl) var(--radius-xl);
    }
    
    .fab {
        right: calc((100vw - 750px) / 2 + 20px);
    }
}

@media screen and (max-width: 320px) {
    .header {
        padding: 12px;
    }
    
    .stats-summary {
        padding: 8px;
    }
    
    .stat-value {
        font-size: 14px;
    }
}