/* SCOPE: #budget-planning-page */
:root {
  --bg: #0b0f14;
  --panel: #121821;
  --text: #e9eef5;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --soft: #1e293b;
  --border: #223047;
}

#budget-planning-page {
    background: var(--bg);
    color: var(--text);
    font: 12px/1.4 system-ui, -apple-system, sans-serif;
    padding: 20px;
}

#budget-planning-page h1 {
    font-size: 22px;
    margin-bottom: 20px;
}

/* 1. TABLE STRUCTURE */
#budget-planning-page .ts-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed; /* Forces columns to respect the widths below */
}

/* Category Column - User Requested: 60px */
#budget-planning-page .ts-table th:first-child,
#budget-planning-page .ts-table td:first-child {
    width: 60px;
    position: sticky;
    left: 0;
    background: #0f1724;
    z-index: 10;
    border-right: 2px solid var(--border) !important;
    overflow: hidden;
    text-overflow: ellipsis; /* Prevents long names from breaking the 60px box */
}

/* Data Columns (History & Forecast) - User Requested: 120px */
#budget-planning-page .ts-table th:not(:first-child),
#budget-planning-page .ts-table td:not(:first-child) {
    width: 120px;
    text-align: right;
}

/* 2. INPUT FIXES (Prevents cutting off numbers) */
#budget-planning-page .plan-input {
    width: 100% !important;
    height: 100% !important;
    background: transparent;
    border: 1px solid transparent;
    color: var(--accent);
    text-align: right;
    font-family: inherit;
    font-weight: 600;
    
    /* Reclaim the space usually reserved for arrows */
    padding: 0 8px !important; 
    margin: 0;
    box-sizing: border-box; /* Includes padding in the 120px width */
    
    /* Remove default browser styles */
    -webkit-appearance: none;
    -moz-appearance: textfield;
}

/* Remove Arrows (Spinners) for all browsers */
#budget-planning-page .plan-input::-webkit-outer-spin-button,
#budget-planning-page .plan-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    display: none;
    margin: 0;
}

/* 3. CELL STYLING */
#budget-planning-page td {
    height: 35px;
    padding: 0 !important; /* Allow input to fill the cell edge-to-edge */
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    vertical-align: middle;
}

/* Make history text look like the input but read-only */
#budget-planning-page td:not(:has(input)) {
    padding: 0 8px !important;
    color: var(--text);
}

/* 4. HEADERS */
#budget-planning-page thead th {
    background: #132033;
    color: var(--muted);
    font-size: 10px;
    text-transform: uppercase;
    padding: 8px;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
}

.history-label { color: var(--text); }
.forecast-label { color: var(--accent); }

/* 5. INTERACTION */
#budget-planning-page .plan-input:hover {
    background: rgba(59, 130, 246, 0.05);
}

#budget-planning-page .plan-input:focus {
    outline: none;
    background: var(--soft);
    border: 1px solid var(--accent);
    color: #fff;
}

/* 6. CONTAINERS */
#budget-planning-page .chart-container {
    height: 280px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 20px;
}

#budget-planning-page .table-container {
    overflow-x: auto;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.view-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.view-controls .btn {
    background: var(--soft);
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.view-controls .btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* Ensure the chart legend is visible and interactive */
canvas#monthlyChart {
    cursor: pointer;
}