/* CleanMat Housing — prevent trainee labels from spilling into adjacent rooms.
   Loaded last so older wide-card rules cannot force overflow. */
@media screen and (min-width: 801px) {
  #layoutPage > .buildings { gap: 14px !important; }
  #layoutPage > .buildings > .building.sakura {
    width: 380px !important; flex: 0 0 380px !important;
  }
  #layoutPage > .buildings > .building.hills {
    width: 1100px !important; flex: 0 0 1100px !important;
  }
  #layoutPage .building { box-sizing: border-box; padding: 12px !important; }
  #layoutPage .hills-plan {
    grid-template-columns: minmax(0, 1.15fr) 26px minmax(0, 1fr) !important;
    gap: 7px !important;
  }
  #layoutPage .apartment, #layoutPage .hills-plan .apartment { min-width: 0; padding: 7px !important; }
  #layoutPage .room-grid, #layoutPage .hills-plan .room-grid { gap: 7px !important; }
  #layoutPage .room, #layoutPage .hills-plan .room { box-sizing: border-box; min-width: 0; padding: 6px !important; }
  #layoutPage .person, #layoutPage .hills-plan .person {
    box-sizing: border-box; width: 100%; max-width: 100%; min-width: 0;
    min-height: 43px; gap: 5px !important; padding: 4px !important;
    overflow: hidden !important;
  }
  #layoutPage .person .photo, #layoutPage .hills-plan .person .photo {
    width: 28px !important; height: 34px !important; flex: 0 0 28px !important;
  }
  #layoutPage .person-details, #layoutPage .hills-plan .person-details {
    display: block; flex: 1 1 0; min-width: 0 !important; max-width: 100%; overflow: hidden;
  }
  #layoutPage .person-name, #layoutPage .hills-plan .person-name {
    display: block; width: 100%; max-width: 100%;
    font-size: 9px !important; line-height: 1.25 !important; letter-spacing: -0.12px;
    white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis;
    word-break: normal !important; overflow-wrap: normal !important;
  }
  #layoutPage .person .workplace, #layoutPage .hills-plan .person .workplace {
    box-sizing: border-box; display: inline-block; vertical-align: top;
    max-width: 100%; font-size: 8px !important; line-height: 1.2 !important;
    margin-top: 3px; padding: 3px 4px !important;
    white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis;
  }
  #housingDragPeople .housing-unassigned-person {
    box-sizing: border-box; flex: 0 0 220px !important; width: 220px !important;
    min-width: 220px !important; max-width: 220px !important;
    overflow: hidden !important;
  }
  #housingDragPeople .housing-unassigned-card, #housingDragPeople .housing-unassigned-text {
    min-width: 0 !important; max-width: 100%; overflow: hidden !important;
  }
  #housingDragPeople .housing-unassigned-text strong,
  #housingDragPeople .housing-unassigned-text .workplace {
    box-sizing: border-box; display: block; max-width: 100% !important;
    white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important;
  }
}
/* Tablet/mobile: protect room boundaries without changing the responsive columns. */
@media screen and (max-width: 800px) {
  #layoutPage .room, #layoutPage .person, #layoutPage .person-details { min-width: 0; max-width: 100%; }
  #layoutPage .person { box-sizing: border-box; overflow: hidden; }
  #layoutPage .person-name, #layoutPage .person .workplace {
    max-width: 100%; overflow: hidden !important; text-overflow: ellipsis;
    white-space: nowrap !important; overflow-wrap: normal !important;
  }
}
