:root {
    --bg-dark: #1a1a2e;
    --bg-card: #232340;
    --bg-input: #2a2a4a;

    --pink-header: #f4a6c6;
    --pink-light: #fce4ec;
    --pink-row: #fdf0f4;
    --pink-hot: #e91e90;
    --pink-total: #f8bbd0;

    --lavender-header: #c5b3e6;
    --lavender-light: #ede7f6;
    --lavender-row: #f3eff9;

    --mint-header: #a8d5ba;
    --mint-light: #e8f5e9;
    --mint-row: #f0f8f2;

    --yellow-header: #ffe082;
    --yellow-light: #fff8e1;

    --text-light: #f0eaf5;
    --text-muted: #a8a3b8;
    --text-dark: #2c2c2c;

    --chart-pink: #e91e90;
    --chart-magenta: #c2185b;
    --chart-lavender: #9c27b0;
    --chart-mint: #66bb6a;
    --chart-gold: #ffd54f;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-dark);
    color: var(--text-light);
    min-height: 100vh;
}

/* ========== HEADER & NAV ========== */
header {
    background: linear-gradient(135deg, #1a1a2e, #2a1f3d);
    padding: 1rem 2rem;
    border-bottom: 2px solid var(--pink-header);
}

header h1 {
    margin-bottom: 1rem;
    font-size: 1.5rem;
    color: var(--pink-header);
}

#main-nav { display: flex; gap: 0.5rem; }

.nav-btn {
    background: var(--bg-card);
    color: var(--text-light);
    border: 1px solid transparent;
    padding: 0.5rem 1.2rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.nav-btn:hover { background: var(--pink-hot); color: white; }
.nav-btn.active { background: var(--pink-hot); color: white; border-color: var(--pink-header); }

/* ========== LAYOUT ========== */
main { padding: 2rem; max-width: 1400px; margin: 0 auto; }
.tab-content { display: none; }
.tab-content.active { display: block; }
h2 { color: var(--pink-header); margin-bottom: 1.5rem; font-size: 1.3rem; }

/* ========== DASHBOARD GRID ========== */
.dash-row {
    display: grid;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.dash-row-3 { grid-template-columns: 280px 1fr 280px; }
.dash-row-3-wide { grid-template-columns: 280px 1fr 1fr; }
.dash-row-equal { grid-template-columns: 1fr 1fr; }

/* ========== CARDS ========== */
.card {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 1.2rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.card h3 {
    margin-bottom: 0.8rem;
    font-size: 0.95rem;
    color: var(--pink-header);
}

/* ========== CALENDAR ========== */
.calendar { text-align: center; }

.calendar-month {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--pink-header);
    margin-bottom: 0.6rem;
    font-style: italic;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    font-size: 0.78rem;
}

.calendar-grid .day-header {
    color: var(--text-muted);
    font-weight: 600;
    padding: 0.3rem 0;
    font-size: 0.7rem;
}

.calendar-grid .day {
    padding: 0.3rem;
    border-radius: 4px;
    color: var(--text-muted);
}

.calendar-grid .day.current-month { color: var(--text-light); }

.calendar-grid .day.today {
    background: var(--pink-hot);
    color: white;
    font-weight: 700;
    border-radius: 50%;
}

.calendar-grid .day.current-week-day {
    background: rgba(233, 30, 144, 0.2);
    border-radius: 4px;
}

/* ========== COMPACT TABLE (forecast-style) ========== */
.compact-table {
    width: 100%;
}

.compact-table .ct-header {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0.6rem;
    border-radius: 6px 6px 0 0;
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--text-dark);
}

.ct-header-pink { background: transparent; color: var(--pink-header); border-bottom: 2px solid var(--pink-header); border-radius: 0; }
.ct-header-lavender { background: transparent; color: var(--lavender-header); border-bottom: 2px solid var(--lavender-header); border-radius: 0; }
.ct-header-mint { background: transparent; color: var(--mint-header); border-bottom: 2px solid var(--mint-header); border-radius: 0; }

.compact-table .ct-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 0.6rem;
    font-size: 0.83rem;
    color: var(--text-dark);
}

.compact-table .ct-row { background: transparent; color: var(--text-light); border-bottom: 1px solid rgba(255,255,255,0.05); }
.compact-table .ct-row.ct-total { background: transparent !important; color: var(--text-light); border-top: 2px solid var(--pink-header); border-bottom: none; }
.compact-table .ct-row.ct-total.lavender-total { border-color: var(--lavender-header); }
.compact-table .ct-row.ct-total.mint-total { border-color: var(--mint-header); }

.ct-label { font-weight: 600; flex: 1; color: var(--text-light); }.ct-label { font-weight: 600; flex: 1; }
.ct-val { text-align: right; min-width: 80px; }
.ct-val + .ct-val { margin-left: 0.5rem; }

.ct-input {
    width: 78px;
    padding: 0.15rem 0.3rem;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 3px;
    font-size: 0.83rem;
    text-align: right;
    background: var(--bg-input);
    color: var(--text-light);
}

.ct-input:focus { outline: none; border-color: var(--pink-hot); }

.actual-highlight { color: var(--pink-hot); font-weight: 700; }

/* 4-column header for tables with Balance */
.ct-header-4 {
    display: grid;
    grid-template-columns: 1fr 80px 80px 80px;
    padding: 0.4rem 0.6rem;
    background: transparent;
    border-bottom: 2px solid var(--pink-header);
    border-radius: 0;
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--pink-header);
    text-align: right;
}

.ct-header-4 > span:first-child { text-align: left; }

.ct-row-4 {
    display: grid;
    grid-template-columns: 1fr 80px 80px 80px;
    align-items: center;
    padding: 0.35rem 0.6rem;
    font-size: 0.83rem;
    color: var(--text-dark);
    text-align: right;
}

.ct-row-4 > span:first-child,
.ct-row-4 > div:first-child { text-align: left; font-weight: 600; }
.ct-row-4 { color: var(--text-light); background: transparent; border-bottom: 1px solid rgba(255,255,255,0.05); }
.ct-row-4.ct-total { border-top: 2px solid var(--pink-header); border-bottom: none; }

/* 5-column for other expenses with action buttons */
.ct-header-5 {
    display: grid;
    grid-template-columns: 1fr 80px 80px 80px 50px;
    padding: 0.4rem 0.6rem;
    background: transparent;
    border-bottom: 2px solid var(--mint-header);
    border-radius: 0;
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--mint-header);
    text-align: right;
}

.ct-header-5 > span:first-child { text-align: left; }

.ct-row-5 {
    display: grid;
    grid-template-columns: 1fr 80px 80px 80px 50px;
    align-items: center;
    padding: 0.35rem 0.6rem;
    font-size: 0.83rem;
    color: var(--text-dark);
    text-align: right;
}

.ct-row-5 > span:first-child,
.ct-row-5 > div:first-child { text-align: left; font-weight: 600; }
.ct-row-5 { color: var(--text-light); background: transparent; border-bottom: 1px solid rgba(255,255,255,0.05); }
.ct-row-5.ct-total { border-top: 2px solid var(--mint-header); border-bottom: none; }

/* ========== CHARTS ========== */
.chart-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
}

/* ========== WEEK NAVIGATION ========== */
.week-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.week-label {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--pink-header);
}

.btn-sm {
    background: var(--bg-card);
    color: var(--text-light);
    border: 1px solid var(--pink-header);
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-sm:hover { background: var(--pink-hot); color: white; }

/* ========== FORMS ========== */
.add-item-form {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    margin-top: 1.5rem;
}

.add-item-form h3 { margin-bottom: 1rem; color: var(--pink-header); }

.form-row {
    display: flex;
    gap: 0.8rem;
    align-items: center;
    flex-wrap: wrap;
}

.form-row select,
.form-row input {
    padding: 0.5rem 0.8rem;
    border: 1px solid #555;
    border-radius: 6px;
    font-size: 0.9rem;
    background: var(--bg-input);
    color: var(--text-light);
}

.form-row input:focus,
.form-row select:focus { outline: none; border-color: var(--pink-hot); }

.btn-add {
    background: var(--pink-hot);
    color: white;
    border: none;
    padding: 0.5rem 1.2rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.btn-add:hover { background: var(--pink-header); color: var(--text-dark); }

.btn-delete {
    background: none;
    border: none;
    color: #cc4444;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.btn-delete:hover { background: rgba(204, 68, 68, 0.2); }

.btn-complete {
    background: none;
    border: 1px solid var(--mint-header);
    color: var(--mint-header);
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
}

.btn-complete:hover { background: var(--mint-header); color: var(--text-dark); }

.empty-state { color: var(--text-muted); font-style: italic; padding: 1rem 0; }

/* ========== DATA TABLES (groceries, expenses, savings) ========== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0.5rem;
}

.data-table th {
    text-align: left;
    padding: 0.6rem 0.8rem;
    border-bottom: 2px solid var(--pink-hot);
    color: var(--pink-header);
    font-size: 0.85rem;
    text-transform: uppercase;
}

.data-table td {
    padding: 0.5rem 0.8rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-light);
}

.inline-input {
    width: 100px;
    padding: 0.3rem 0.5rem;
    border: 1px solid #555;
    border-radius: 4px;
    font-size: 0.9rem;
    background: var(--bg-input);
    color: var(--text-light);
}

.inline-input:focus { outline: none; border-color: var(--pink-hot); }

.section-total {
    margin-top: 0.8rem;
    padding-top: 0.8rem;
    border-top: 2px solid var(--pink-header);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.grocers-section {
    margin-bottom: 2rem;
    background: var(--bg-card);
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.grocers-section h3 { margin-bottom: 1rem; color: var(--pink-header); }

/* ========== SAVINGS ========== */
.savings-card {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.savings-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.savings-header h3 { color: var(--pink-header); margin: 0; }
.savings-actions { display: flex; gap: 0.5rem; }

.progress-bar {
    width: 100%;
    height: 12px;
    background: var(--bg-input);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--pink-hot), var(--pink-header));
    border-radius: 6px;
    transition: width 0.3s ease;
}

.savings-stats { display: flex; justify-content: space-between; font-size: 0.9rem; color: var(--text-muted); margin-bottom: 0.3rem; }
.savings-remaining { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1rem; }

.deposit-row { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; margin-top: 0.5rem; }

.deposit-row input {
    padding: 0.5rem 0.8rem;
    border: 1px solid #555;
    border-radius: 6px;
    font-size: 0.9rem;
    background: var(--bg-input);
    color: var(--text-light);
}

.deposit-row input:focus { outline: none; border-color: var(--pink-hot); }
.txn-list { margin-top: 0.5rem; }

/* ========== FORECAST ========== */
.forecast-card {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    border-left: 4px solid var(--text-muted);
}

.forecast-card.current-week { border-left-color: var(--pink-hot); }

.forecast-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.forecast-header h3 { color: var(--text-light); margin: 0; }

.badge {
    background: var(--pink-hot);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.forecast-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
}

.forecast-block h4 { color: var(--text-muted); margin-bottom: 0.8rem; font-size: 0.9rem; }

.forecast-row {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem 0;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-light);
}

.forecast-row.total {
    border-top: 2px solid var(--pink-header);
    border-bottom: none;
    font-weight: 700;
    padding-top: 0.5rem;
    margin-top: 0.3rem;
}

.negative { color: #ff5252; }

/* ========== RESPONSIVE ========== */
@media (max-width: 1100px) {
    .dash-row-3, .dash-row-3-wide { grid-template-columns: 1fr; }
    .dash-row-equal { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; align-items: stretch; }
    #main-nav { flex-wrap: wrap; }
}

/* ========== GROCERY TABLE ========== */
.grocery-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.83rem;
}

.grocery-header-top th,
.grocery-header-sub th {
    padding: 0.4rem 0.5rem;
    color: var(--pink-header);
    font-size: 0.78rem;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.gt-group-header {
    text-align: center !important;
    font-size: 0.85rem !important;
    letter-spacing: 0.5px;
}

.gt-proj-group { border-bottom: 2px solid var(--lavender-header) !important; }
.gt-act-group { border-bottom: 2px solid var(--pink-header) !important; }

.gt-sub {
    text-align: center !important;
    font-size: 0.72rem !important;
    color: var(--text-muted) !important;
}

.gt-item { text-align: left !important; }
.gt-bal { text-align: center !important; }

.gt-border-right { border-right: 1px solid rgba(255,255,255,0.1); }

.grocery-row td {
    padding: 0.35rem 0.5rem;
    color: var(--text-light);
    border-bottom: 1px solid rgba(255,255,255,0.04);
    text-align: center;
}

.gt-drag {
    cursor: grab;
    color: var(--text-muted);
    font-size: 0.9rem;
    user-select: none;
    width: 30px;
    text-align: center !important;
}

.gt-drag:active { cursor: grabbing; }

.gt-item-name {
    text-align: left !important;
    font-weight: 600;
}

.gt-input {
    width: 65px;
    padding: 0.15rem 0.3rem;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 3px;
    font-size: 0.83rem;
    text-align: right;
    background: var(--bg-input);
    color: var(--text-light);
}

.gt-input:focus { outline: none; border-color: var(--pink-hot); }
.gt-input.gt-count { width: 45px; }

.gt-amount {
    font-weight: 600;
    color: var(--text-light);
}

.gt-balance {
    font-weight: 600;
    color: var(--mint-header);
}

.grocery-total td {
    padding: 0.6rem 0.5rem;
    border-top: 2px solid var(--pink-header);
    color: var(--pink-header);
    font-weight: 700;
    font-size: 0.95rem;
    text-align: center;
}

.grocery-row.drag-over {
    border-top: 2px solid var(--pink-hot);
}

.grocery-row[draggable="true"] {
    transition: opacity 0.2s;
}