/* --- Layout: desktop default --- */
main {
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: 0;
}

/* Ensure the panel actually occupies the left column */
#budget-panel {
  background: #fff;
  border-right: 1px solid #ddd;
  overflow: auto;
  min-height: 0; /* important for grid children + scrolling */
}

/* --- Budget panel typography & alignment (ALL SIZES) --- */
#budget-panel .bp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid #eee;
}

#budget-panel .bp-title {
  font-weight: 800;
}

#budget-panel .bp-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid #f0f0f0;
}

#budget-panel .bp-controls label {
  display: grid;
  grid-template-columns: 80px 1fr;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: #333;
}

#budget-panel .bp-controls select {
  width: 100%;
}

/* Cards */
#budget-panel .bp-card {
  padding: 10px 12px;
  border-bottom: 1px solid #f2f2f2;
}

/* KPI block: label left, value right */
#budget-panel .bp-kpi {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
}

#budget-panel .bp-kpi-label {
  font-size: 0.80rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #555;
}

#budget-panel .bp-kpi-value {
  font-size: 1.15rem;
  font-weight: 900;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Rows: label left, value right */
#budget-panel .bp-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 3px 0;
}

#budget-panel .bp-row-label {
  font-weight: 800;        /* bold headings */
  color: #333;
}

#budget-panel .bp-row-value {
  margin-left: auto;
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Muted helper text */
#budget-panel .bp-muted {
  opacity: 0.7;
  font-weight: 600;
}

/* panel must allow scrolling content */
#budget-panel { overflow: auto; }

/* chart + table should be normal-flow blocks */
#bp-chart { display: block; width: 100%; height: auto; }
#bp-chart-table { display: block; position: relative; z-index: 1; margin-top: 10px; }

/* if you have a chart wrapper that is absolute/fixed, this prevents overlap */
#bp-chart-wrap, #bp-charts { position: relative; }

/* table should not exceed width on mobile */
#bp-chart-table { overflow-x: auto; }
#bp-chart-table table { width: 100%; border-collapse: collapse; }
#bp-chart-table th, #bp-chart-table td { padding: 6px 8px; white-space: nowrap; }

/* --- Mobile override: slide-down panel --- */
@media (max-width: 900px) {
  main {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;  /* if you have multiple areas */
  }

  /* Give the map a predictable height */
  #map {
    height: 45vh;
  }

  /* Budget panel becomes bottom sheet */
  #budget-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;

    max-height: 55vh;
    overflow: auto;

    z-index: 20000;
    transform: none;            /* IMPORTANT: stop hiding it */
    transition: none;

    border-right: none;
    border-top: 1px solid rgba(0,0,0,.12);
    box-shadow: 0 -6px 18px rgba(0,0,0,.18);
    background: #fff;
  }

  #budget-panel .bp-header {
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
  }
}