
:root { --bg-color: #fdfcf0; --card-bg: #ffffff; --text-primary: #333; --text-secondary: #757575; --accent-green-bg: #e0f2f1; --accent-green-text: #00695c; --accent-red-bg: #ffebee; --accent-red-text: #c62828; --shadow: 0 4px 12px rgba(0,0,0,0.05); }
* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Poppins', sans-serif; }
body { background-color: var(--bg-color); color: var(--text-primary); display: flex; justify-content: center; min-height: 100vh; }
body.modal-open { overflow: hidden; height: 100vh; }

.login-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #fdfcf0; z-index: 9999; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: white; padding: 30px; border-radius: 24px; box-shadow: 0 10px 25px rgba(0,0,0,0.1); width: 100%; max-width: 350px; text-align: center; }
.login-icon { background: #000; color: white; width: 60px; height: 60px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 20px auto; }
.login-icon span { font-size: 30px; }
.login-card h2 { margin-bottom: 10px; font-weight: 600; }
.login-card p { color: #777; margin-bottom: 20px; font-size: 0.9rem; }
.login-card input { text-align: center; letter-spacing: 5px; font-size: 1.5rem; font-weight: bold; margin-bottom: 15px; }

.app-container { width: 100%; max-width: 480px; padding: 20px; padding-bottom: 80px; transition: max-width 0.3s; }

@media (min-width: 700px) {
    .app-container { max-width: 1200px; }
    .main-layout { display: flex; gap: 30px; align-items: flex-start; }
    .layout-left { flex: 1; position: sticky; top: 20px; }
    .layout-right { flex: 1.5; }
    header { margin-bottom: 30px; }
}

header { display: flex; flex-direction: column; margin-bottom: 25px; gap: 10px; }
.header-top { display: flex; justify-content: space-between; align-items: center; }
h1 { font-weight: 600; font-size: 1.5rem; display: flex; align-items: center; gap: 8px; }
#current-date { font-size: 0.9rem; color: var(--text-secondary); }
.project-bar { display: flex; align-items: center; background: white; padding: 8px 12px; border-radius: 12px; box-shadow: var(--shadow); gap: 10px; }
.project-bar select { border: none; background: transparent; padding: 5px; font-weight: 600; font-size: 1rem; flex: 1; outline: none; }
.small-icon { font-size: 1.2rem; color: #555; }
.mini-btn-transparent { background: none; border: 1px solid #ddd; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 1.2rem; display:flex; align-items:center; justify-content:center; }
.header-actions { display: flex; gap: 10px; }
.icon-btn { background: white; border: none; padding: 8px; border-radius: 50%; box-shadow: var(--shadow); cursor: pointer; display: flex; align-items: center; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.status-dot.red { background-color: #ff5252; box-shadow: 0 0 5px #ff5252; }
.status-dot.green { background-color: #4caf50; box-shadow: 0 0 5px #4caf50; }
.cards-container { display: flex; flex-direction: column; gap: 15px; margin-bottom: 25px; }
.card { background: var(--card-bg); border-radius: 24px; padding: 20px; box-shadow: var(--shadow); }
.balance-card { display: flex; align-items: center; gap: 15px; background: #2d3436; color: white; }
.balance-card .icon-bg { background: rgba(255,255,255,0.2); padding: 10px; border-radius: 50%; display: flex; }
.balance-card h2 { font-size: 1.8rem; }
.row-cards { display: flex; gap: 15px; }
.row-cards .card { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.income-card { background-color: var(--accent-green-bg); color: var(--accent-green-text); }
.expense-card { background-color: var(--accent-red-bg); color: var(--accent-red-text); }
.card-header { display: flex; align-items: center; gap: 5px; font-size: 0.9rem; font-weight: 500; }
.actions { margin-bottom: 20px; }
.action-btn { width: 100%; background: #000; color: white; padding: 15px; border-radius: 18px; border: none; font-size: 1rem; font-weight: 500; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px; }
.filters-section { margin-bottom: 15px; }
.search-container { position: relative; margin-bottom: 10px; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #888; }
.search-container input { width: 100%; padding: 12px 12px 12px 40px; border-radius: 12px; border: none; background: #fff; box-shadow: var(--shadow); outline: none; }

.type-tabs { display: flex; background: #e0e0e0; padding: 4px; border-radius: 12px; margin-bottom: 10px; }
.type-tab { flex: 1; border: none; background: transparent; padding: 10px; border-radius: 10px; font-weight: 600; cursor: pointer; color: #777; transition: 0.2s; }
.type-tab.active { background: white; color: #000; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }

.filter-row { display: flex; gap: 10px; justify-content: space-between; align-items: center; }
.filter-row select { padding: 10px; font-size: 0.9rem; border-radius: 10px; border: none; background: white; box-shadow: 0 2px 5px rgba(0,0,0,0.03); width: 100%; }
.filter-row input { flex: 1; padding: 8px; border-radius: 10px; border: 1px solid #ddd; }
.full-width-date { width: 100%; }
.date-input-group { display: flex; width: 100%; gap: 5px; align-items: center; }

#date-sep { font-size: 0.9rem; color: #777; }
.date-header { font-size: 0.85rem; font-weight: 600; color: #777; margin: 15px 0 8px 5px; text-transform: uppercase; letter-spacing: 0.5px; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.transaction-item { background: white; padding: 15px; border-radius: 18px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 2px 8px rgba(0,0,0,0.02); cursor: pointer; transition: transform 0.1s; }
.transaction-item:active { transform: scale(0.98); }
.t-left { display: flex; gap: 12px; align-items: center; }
.t-icon { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; }
.t-title { font-weight: 600; font-size: 0.95rem; }
.t-cat { font-size: 0.8rem; color: var(--text-secondary); }
.t-amount { font-weight: 600; font-size: 1rem; }
.is-income { color: var(--accent-green-text); }
.is-expense { color: var(--accent-red-text); }
.chart-section { display: flex; align-items: center; justify-content: space-around; margin-bottom: 25px; padding: 10px; background: #f9f9f9; border-radius: 15px; }
.pie-chart { width: 120px; height: 120px; border-radius: 50%; background: #eee; flex-shrink: 0; box-shadow: inset 0 0 10px rgba(0,0,0,0.1); }
.chart-legend { display: flex; flex-direction: column; gap: 8px; font-size: 0.85rem; max-height: 120px; overflow-y: auto; padding-right: 5px; }
.legend-item { display: flex; align-items: center; gap: 8px; }
.legend-color { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.modal { display: none; position: fixed; z-index: 100; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); align-items: flex-end; }
#categoryModal, #projectModal { z-index: 200 !important; }
#transactionModal { z-index: 300 !important; }

.modal-content.full-height-modal { display: flex; flex-direction: column; max-height: 85vh; padding-bottom: 0; }
.cat-form-container { flex-shrink: 0; padding-bottom: 15px; border-bottom: 1px solid #eee; }
.category-list-wrapper { flex-grow: 1; display: flex; flex-direction: column; overflow: hidden; margin-top: 15px; }
.search-wrapper { flex-shrink: 0; margin-bottom: 10px; }
.scrollable-list { flex-grow: 1; overflow-y: auto; padding-bottom: 20px; }

.modal-content { background-color: #fefefe; width: 100%; max-width: 480px; margin: 0 auto; border-radius: 25px 25px 0 0; padding: 25px; animation: slideUp 0.3s ease; }
.modal-content.large-modal { height: 85vh; display: flex; flex-direction: column; overflow: hidden; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-shrink: 0; }
.close { font-size: 28px; font-weight: bold; cursor: pointer; }
.project-badge { font-size: 0.8rem; background: #eee; padding: 5px 10px; border-radius: 6px; margin-bottom: 15px; display: inline-block; align-self: flex-start; font-weight: 500; }
.form-group { margin-bottom: 15px; }
.form-group.half { width: 48%; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 500; font-size: 0.9rem; }
input, select { width: 100%; padding: 12px; border: 1px solid #ddd; border-radius: 12px; font-size: 1rem; outline: none; background: #f9f9f9; }
.switch-field { display: flex; margin-bottom: 20px; overflow: hidden; border-radius: 12px; border: 1px solid #ddd; }
.switch-field input { display: none; }
.switch-field label { flex: 1; text-align: center; padding: 12px; cursor: pointer; transition: 0.2s; }
.switch-field input:checked + label { background-color: #000; color: #fff; }
.row-input { display: flex; justify-content: space-between; }
.input-with-btn { display: flex; gap: 8px; }
.mini-btn { width: 50px; background: #000; color: white; border: none; border-radius: 12px; font-size: 1.5rem; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.mini-btn-red { width: 40px; background: #ffebee; color: #c62828; border: none; border-radius: 10px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.save-btn { width: 100%; padding: 15px; background: #000; color: white; border: none; border-radius: 15px; font-size: 1rem; font-weight: 500; cursor: pointer; margin-top: 10px; }
.small-save-btn { padding: 10px; font-size: 0.9rem; } /* Squeezed Form Button */
.danger-btn { width: 100%; padding: 12px; background: #ffeba8; color: #5a4a00; border: none; border-radius: 12px; cursor: pointer; }
.secondary-btn { width: 100%; padding: 10px; border-radius: 8px; border: 1px solid #333; background: transparent; cursor: pointer; text-align: center; }
#report-output { overflow-y: auto; margin-top: 20px; flex: 1; }
.report-group { margin-bottom: 20px; }
.report-header { display: flex; justify-content: space-between; font-weight: 600; padding: 10px; background: #f0f0f0; border-radius: 8px; align-items:center; cursor: pointer; transition: 0.1s; }
.report-header:hover { background: #e0e0e0; }
.report-row { display: flex; justify-content: space-between; padding: 8px 10px; border-bottom: 1px solid #eee; font-size: 0.9rem; }
.report-summary { margin-top: 20px; padding: 15px; background: #000; color: white; border-radius: 12px; display: flex; justify-content: space-between; font-weight: 600; }
.cat-item { display: flex; justify-content: space-between; padding: 10px; border-bottom: 1px solid #eee; align-items: center; }
.cat-actions { display:flex; gap:10px; }
.action-icon { cursor:pointer; font-size:1.1rem; }
.del-icon { color: red; }
.edit-icon { color: #555; }
.fav-icon { color: #ccc; transition: 0.2s; }
.fav-icon.is-default { color: #fbc02d; font-variation-settings: 'FILL' 1; }
.report-controls { display:flex; gap:5px; align-items:center; flex-wrap:wrap; }
.sub-chip-container { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.sub-chip { background: #e0f2f1; color: #00695c; padding: 5px 10px; border-radius: 15px; font-size: 0.85rem; display: flex; align-items: center; gap: 5px; }
.sub-chip span { cursor: pointer; font-weight: bold; color: #c62828; }
.sub-chip span.sub-text { color:#00695c; font-weight:normal; margin-right:5px; }
.sub-chip span:hover { color: red; }

/* MODIFIED: Suggestion list now appears ABOVE the input */
.suggestions-list {
    position: absolute;
    bottom: 100%; /* Floats above the input */
    left: 0;
    width: 100%;
    background: white;
    border: 1px solid #ddd;
    border-radius: 12px 12px 12px 12px; /* Uniform rounded */
    max-height: 200px;
    overflow-y: auto;
    z-index: 10000; /* High Z-Index to stay on top */
    box-shadow: 0 -4px 10px rgba(0,0,0,0.1); /* Shadow pointing up */
    display: none; 
    margin-bottom: 5px; /* Slight gap from input */
}
/* Reduce height on small screens */
@media (max-height: 600px) {
    .suggestions-list {
        max-height: 140px;
    }
}
.suggestions-list div {
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    font-size: 0.95rem;
}
.suggestions-list div:hover {
    background-color: #f9f9f9;
}
.suggestions-list div:last-child {
    border-bottom: none;
}
