/* Stable mid-size layout: prevent dashboard panels and calendar controls from overflowing. */
.calendar-card .calendar {
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-template-rows: 34px repeat(5, minmax(72px, 1fr));
  grid-auto-rows: unset;
  overflow: hidden;
}
.calendar-card .dow { min-width: 0; display: grid; place-items: center; padding: 4px; white-space: nowrap; }
.calendar-card .day { min-width: 0; min-height: 0; height: auto; aspect-ratio: auto; overflow: hidden; }
.calendar-card .event { max-width: 100%; }
.calendar-head { display: grid; grid-template-columns: 32px max-content 32px minmax(0, 1fr) max-content; gap: 8px; min-width: 0; }
.calendar-head h2 { white-space: nowrap; font-size: 20px; margin: 0 3px; }
.calendar-head .calendar-legend { min-width: 0; margin-left: 0; justify-content: flex-end; gap: 10px; white-space: nowrap; overflow: hidden; }
.calendar-head .calendar-legend span { font-size: 11px; white-space: nowrap; }
.calendar-head .outline { margin-left: 0; white-space: nowrap; }

@media (max-width: 1450px) {
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
  .right-column { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: 290px; }
  .right-column .mail-card, .right-column .messages { min-height: 290px; }
  .left-column { min-height: 0; }
}

@media (max-width: 1120px) {
  .calendar-head { grid-template-columns: 30px max-content 30px 1fr max-content; gap: 5px; }
  .calendar-head h2 { font-size: 18px; }
  .calendar-head .calendar-legend { display: none; }
  .calendar-head .outline { height: 30px; padding: 0 8px; font-size: 11px; }
  .calendar-card .calendar { grid-template-rows: 32px repeat(5, minmax(62px, 1fr)); }
}

@media (max-width: 920px) {
  .right-column { grid-template-columns: 1fr; grid-template-rows: auto; }
  .right-column .mail-card, .right-column .messages { min-height: 250px; }
  .top-workspace, .bottom-workspace { grid-template-columns: 1fr; }
  .calendar-card .calendar { grid-template-rows: 32px repeat(5, minmax(58px, 1fr)); }
}
