/* ===== rc_budget_html (HTML form) =====
   Loaded eagerly from anvil.yaml native_deps.head_html.

   NO :where() SCOPE, ON PURPOSE. This form keeps TWO top-level nodes — the section and the staff
   drill-down overlay, which initBudget reparents into #rc-dashboard — so Anvil holds its own wrapper
   as the form root and no element carries a form root class to scope on. That is safe only while
   every selector below is either id-led or a name declared nowhere else in the repo:
   rc-budget-*, rc-month-*, rc-treemap-container, rc-modal-stat*, rc-staff-* and
   rc-unpublished-badge are each declared in this file alone. A future rule here that is neither
   id-led nor privately named would leak into every other RotaCloud section with no scope to stop it.

   The parent's dark-mode override outranks this file on specificity, not on order, so link
   order does not matter: [data-theme="dark"] .rc-month-badge.current is (0,3,0) against (0,2,0).
   No rule here needs a second class. A third parent rule reaches the overlay: rotacloud.css's
   .rc-dashboard > *:not(.px-loading-overlay) { position: relative } at (0,2,0), which applies because
   initBudget reparents the overlay to be a direct child of #rc-dashboard. That one is answered by the
   id-led rule in the modal section below. */

.rc-budget-section {
    font-family: var(--px-font-display);
}

/* =============================================
   TWO-COLUMN GRID FOR MONTHS
   ============================================= */
.rc-budget-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 900px) {
    .rc-budget-grid {
        grid-template-columns: 1fr;
    }
}

.rc-budget-month {
    background: var(--px-bg-elevated);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

.rc-month-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.rc-month-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--px-text-primary);
}

.rc-month-badge {
    font-family: 'Space Mono', monospace;
    font-size: 0.6rem;
    padding: 3px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

.rc-month-badge.current {
    background: rgba(13, 148, 136, 0.12);
    color: color-mix(in srgb, var(--px-chart-teal) 65%, var(--px-text-primary));
    border: 1px solid rgba(13, 148, 136, 0.25);
}

.rc-month-badge.next {
    background: rgba(79, 70, 229, 0.12);
    color: var(--px-chart-indigo);
    border: 1px solid rgba(79, 70, 229, 0.25);
}

/* =============================================
   MINI STATS ROW
   ============================================= */
.rc-month-stats {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.rc-month-stat {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
}

.rc-month-stat-value {
    font-family: 'Space Mono', monospace;
    font-size: 0.95rem;
    font-weight: 700;
    color: color-mix(in srgb, var(--px-chart-teal) 65%, var(--px-text-primary));
}

.rc-month-stat-value.cost {
    color: color-mix(in srgb, var(--px-chart-emerald) 65%, var(--px-text-primary));
}

.rc-month-stat-label {
    font-size: 0.6rem;
    color: var(--px-text-muted);
    text-transform: uppercase;
}

/* =============================================
   TREEMAP CONTAINER
   ============================================= */
.rc-treemap-container {
    height: 280px;
    min-height: 200px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--px-bg-card);
    flex: 1;
}

/* =============================================
   MODAL STYLES
   ============================================= */
.rc-budget-modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.rc-budget-modal-overlay.visible {
    display: flex;
}

/* initBudget makes the overlay a direct child of #rc-dashboard on every mount, so
   rotacloud.css's .rc-dashboard > *:not(.px-loading-overlay) { position: relative } at (0,2,0)
   beats the (0,1,0) class rule above and the overlay drops into normal flow. Id-led at (1,0,0)
   so it wins wherever the overlay is parked. */
#budget-modal-overlay {
    position: fixed;
}

.rc-budget-modal {
    background: var(--px-bg-card);
    border-radius: 16px;
    width: 100%;
    max-width: 800px;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.rc-budget-modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--px-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.rc-budget-modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--px-text-primary);
}

.rc-budget-modal-subtitle {
    font-size: 0.75rem;
    color: var(--px-text-muted);
    margin-top: 0.125rem;
}

.rc-budget-modal-close {
    width: 32px; height: 32px;
    border: none;
    background: var(--px-bg-elevated);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--px-text-muted);
    transition: opacity 0.2s ease, transform 0.2s ease, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.rc-budget-modal-close:hover {
    background: var(--px-border);
    color: var(--px-text-primary);
}

.rc-budget-modal-body {
    padding: 1.5rem;
    max-height: calc(85vh - 80px);
    overflow-y: auto;
}

.rc-modal-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.rc-modal-stat {
    background: var(--px-bg-elevated);
    border-radius: 10px;
    padding: 0.75rem;
    text-align: center;
}

.rc-modal-stat-value {
    font-family: 'Space Mono', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    color: color-mix(in srgb, var(--px-chart-teal) 65%, var(--px-text-primary));
}

.rc-modal-stat-label {
    font-size: 0.65rem;
    color: var(--px-text-muted);
    text-transform: uppercase;
}

.rc-staff-table-wrapper {
    overflow-x: auto;
    border-radius: 10px;
    border: 1px solid var(--px-border);
}

.rc-staff-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.rc-staff-table th {
    background: var(--px-bg-elevated);
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--px-text-secondary);
    border-bottom: 1px solid var(--px-border);
    white-space: nowrap;
}

.rc-staff-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--px-border);
    color: var(--px-text-primary);
}

.rc-staff-table tr:last-child td { border-bottom: none; }
.rc-staff-table tr:hover td { background: var(--px-bg-elevated); }

.rc-staff-name { font-weight: 600; }
.rc-staff-hours { font-family: 'Space Mono', monospace; color: color-mix(in srgb, var(--px-chart-teal) 65%, var(--px-text-primary)); font-weight: 600; }
.rc-staff-cost { font-family: 'Space Mono', monospace; color: color-mix(in srgb, var(--px-chart-emerald) 65%, var(--px-text-primary)); font-weight: 600; }
.rc-staff-date { font-family: 'Space Mono', monospace; font-size: 0.7rem; color: var(--px-text-muted); }

.rc-unpublished-badge {
    font-family: 'Space Mono', monospace;
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: 6px;
    background: var(--px-warning-bg);
    color: var(--px-warning-text);
    border: 1px solid var(--px-warning-border);
}

@media (max-width: 640px) {
    .rc-treemap-container { height: 220px; }
    .rc-budget-modal { max-height: 90vh; }
    .rc-staff-table { font-size: 0.75rem; }
    .rc-staff-table th, .rc-staff-table td { padding: 0.5rem 0.75rem; }
}
