:root {
    --primary-color: #4d7db0; /* Blue for primary actions/branding */
    --secondary-color: #6c757d; /* Gray for secondary actions */
    --success-color: #28a745; /* Green for success/export */
    --danger-color: #dc3545; /* Red for deletion/alerts */
    --background-light: #f8f9fa; /* Very light gray for overall background */
    --card-background: #ffffff; /* White for card areas */
    --border-color: #dee2e6;
    --text-color: #343a40;
    --shadow-light: 0 0.5rem 1rem rgba(0, 0, 0, 0.05); /* Subtle shadow */
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}

body {
    font-family: var(--font-family);
    background-color: var(--background-light);
    color: var(--text-color);
    padding: 20px;
    line-height: 1.6;
}
body {
    font-family: 'Arial', sans-serif;
    background-color: #f4f4f9;
    color: #333;
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
}

.container {
    background: #ffffff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 900px;
}

h1, h2, h3 {
    color: #0c335c;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
    margin-top: 0;
}

/* --- Input Group (Paycheck) --- */
.input-group {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
}

.input-group label {
    font-weight: bold;
    margin-right: 15px;
    min-width: 180px;
}

.input-group input[type="number"] {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1.1em;
    width: 150px;
    text-align: right;
}

hr {
    border: 0;
    height: 1px;
    background: #ccc;
    margin: 20px 0;
}

/* --- Table Structure (Allocation Rows) --- */

.allocation-row {
    display: grid;
    grid-template-columns: 3fr 1fr 1fr 50px; /* Name | Percent | Amount | Delete */
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
    align-items: center;
}

.allocation-row.header {
    font-weight: bold;
    background-color: #f9f9f9;
    border-top: 2px solid #ddd;
    border-bottom: 2px solid #ddd;
    padding: 10px 0;
}

/* Ensure header text alignment matches inputs */
.allocation-row.header .percent-input,
.allocation-row.header .calculated-value {
    text-align: right;
    padding-right: 5px; /* Adjust padding to match input text position */
}

/* --- Input Field Styling --- */

.allocation-row input[type="text"] {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
}

.percent-input-field,
.amount-input-field {
    text-align: right;
}

/* --- Action Buttons (Table Actions) --- */
.table-actions, .preset-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.action-button {
    padding: 10px 15px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s ease;
}

/* Primary buttons (Load, Save) */
.primary-button {
    background-color: #0c335c;
    color: white;
}

.primary-button:hover {
    background-color: #0c335c;
}

/* Secondary buttons (Preset, Split Difference) */
.secondary-button {
    background-color: #6c757d;
    color: white;
}

.secondary-button:hover {
    background-color: #5a6268;
}

.delete-btn {
    background: none;
    border: none;
    color: #dc3545; /* Red color */
    cursor: pointer;
    font-size: 1.2em;
    padding: 0;
    margin: 0 auto; /* Center the delete icon */
    display: block;
    width: fit-content;
}

.delete-btn:hover {
    color: #a71d2a;
}

/* --- Total and Remaining Bars (Crucial Updates) --- */

.allocation-row.total,
.allocation-row.remaining {
    font-weight: bold;
    border-top: 2px solid #ddd;
    padding: 15px 0;
    background-color: #e9ecef; /* Light gray background for totals */
    font-size: 1.1em;
}

.allocation-row.total {
    color: #333;
}

.allocation-row.remaining {
    color: #28a745; /* Green for remaining */
    border-bottom: 2px solid #ddd;
    margin-bottom: 15px;
}

/* Ensure total/remaining values align right */
.allocation-row.total .percent-input,
.allocation-row.total .calculated-value,
.allocation-row.remaining .percent-input,
.allocation-row.remaining .calculated-value {
    text-align: right;
    padding-right: 5px;
}

/* --- Alerts and Messages --- */
.alert-message {
    padding: 10px;
    margin: 15px 0;
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    display: none; /* Hidden by default */
    font-weight: bold;
}

.alert-percent {
    color: #dc3545; /* Red for percentage over 100% */
}

/* --- Custom Category Adder --- */

.custom-adder {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 15px 0;
    flex-wrap: wrap;
}

.custom-adder h3 {
    margin: 0;
    flex-basis: 100%; /* Ensure heading takes full width */
    border-bottom: none;
}

.custom-adder input[type="text"],
.custom-adder input[type="number"] {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.custom-adder input[type="text"] {
    flex-grow: 1;
    min-width: 200px;
}

.custom-adder input[type="number"] {
    width: 80px;
    text-align: right;
}

.custom-adder button {
    padding: 8px 15px;
    background-color: #0c335c;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

.custom-adder button:hover {
    background-color: #0c335c;
}

/* --- Tooltip Styles --- */

/* Adjust preset actions to handle new groups */
.preset-actions {
    /* Existing styles: */
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

/* Style for the button + info icon group */
.preset-group {
    display: flex;
    align-items: center;
    gap: 5px;
    position: relative; /* Needed for positioning the tooltip trigger */
}

/* Style for the info icon */
.tooltip-trigger {
    color: #0c335c;
    cursor: pointer;
    font-size: 1.1em;
    transition: color 0.2s;
}

.tooltip-trigger:hover {
    color: #0c335c;
}

/* Container for all tooltips (placed near the top of the container) */
#tooltipContainer {
    position: relative;
    height: 0; /* Consume no vertical space */
    width: 100%;
    margin-bottom: 20px;
}

/* Style for the actual tooltip box */
.budget-tooltip {
    position: absolute;
    top: 5px; /* Pushes the box slightly down from the top */
    left: 0;
    z-index: 10;
    
    background-color: #ffffe0; /* Light yellow/cream color for distinction */
    color: #333;
    padding: 15px;
    border: 1px solid #ffcc00;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    
    width: 95%; 
    max-width: 600px;
    display: none; /* Crucial: Hidden by default */
    line-height: 1.4;
    font-size: 0.95em;
}

.budget-tooltip strong {
    color: #0c335c;
}

/* --- New Input Group Styling --- */
.input-actions-group {
    display: flex;
    align-items: center;
    gap: 10px; /* Space between input, button, and icon */
    margin-bottom: 15px;
}

.input-actions-group input {
    /* Ensure the input doesn't stretch too wide */
    max-width: 150px; 
}

.compact-button {
    /* Make the button look less imposing */
    padding: 8px 12px; 
    font-size: 0.9em;
}

/* Style for the active Monthly toggle button */
.compact-button.active {
    background-color: #28a745; /* Green color when active */
    color: white;
}