:root {
    --primary-color: #2196F3;
    --primary-dark: #1976D2;
    --accent-color: #FF4081;
    --bg-color: #f5f7f9;
    --card-bg: #ffffff;
    --text-main: #333333;
    --text-secondary: #666666;
    --expense-color: #f44336;
    --income-color: #4caf50;
    --border-color: #e0e0e0;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 16px;
}

header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 40px 0 60px;
    border-radius: 0 0 24px 24px;
    margin-bottom: 24px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    text-align: center;
}

h1 {
    font-size: 1.5rem;
    margin-bottom: 24px;
    font-weight: 500;
}

.stats-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 8px 16px rgba(0,0,0,0.08);
    color: var(--text-main);
}

.stat-item {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.stat-item.separator {
    flex: 0 0 1px;
    height: 40px;
    background-color: var(--border-color);
    margin: 0 16px;
}

.stat-item .label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-item .value {
    font-size: 1.4rem;
    font-weight: bold;
}

.text-red { color: var(--expense-color); }
.text-blue { color: var(--primary-color); }

.card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.chart-container {
    position: relative;
    height: 250px;
    width: 100%;
    display: flex;
    justify-content: center;
}

.icon-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--primary-color);
    color: white;
}

.icon-btn .material-icons {
    font-size: 1.2rem;
}

main {
    padding-bottom: 80px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 24px 0 16px;
}

h2 {
    font-size: 1.1rem;
    color: var(--text-main);
}

select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: white;
    outline: none;
}

.record-list {
    list-style: none;
    background: var(--card-bg);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.record-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

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

.record-item:active {
    background-color: #f0f0f0;
}

.record-info {
    display: flex;
    flex-direction: column;
}

.record-category {
    font-weight: 500;
}

.record-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.record-amount {
    font-weight: bold;
    font-size: 1.1rem;
}

.empty-msg {
    padding: 40px;
    text-align: center;
    color: var(--text-secondary);
}

/* FAB (Floating Action Button) */
.fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--accent-color);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: transform 0.2s;
}

.fab:active {
    transform: scale(0.9);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 200;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--card-bg);
    width: 90%;
    max-width: 450px;
    border-radius: 20px;
    padding: 24px;
    position: relative;
    animation: slideIn 0.3s ease-out;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.close-btn {
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    font-weight: 500;
}

input[type="number"], 
input[type="text"], 
input[type="date"], 
select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
}

.type-toggle {
    display: flex;
    background: #eee;
    padding: 4px;
    border-radius: 12px;
}

.type-toggle input {
    display: none;
}

.type-toggle label {
    flex: 1;
    text-align: center;
    padding: 8px;
    margin-bottom: 0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

#type-expense:checked + label {
    background: var(--expense-color);
    color: white;
}

#type-income:checked + label {
    background: var(--income-color);
    color: white;
}

.submit-btn {
    width: 100%;
    padding: 14px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    margin-top: 10px;
}

/* Category Management */
.category-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

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

.delete-cat-btn {
    background: transparent;
    border: none;
    color: var(--expense-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 4px;
    border-radius: 4px;
}

.delete-cat-btn:hover {
    background: #ffebee;
}

/* PC Responsive */
@media (min-width: 850px) {
    header {
        padding: 60px 0 80px;
        border-radius: 0 0 40px 40px;
    }
    
    .stats-card {
        padding: 32px;
        margin-top: -40px;
    }
    
    .record-item:hover {
        background-color: #fafafa;
    }
    
    .fab {
        bottom: 50px;
        right: 50px;
        width: 70px;
        height: 70px;
    }
}
