.m2-referral-widget {
  min-width: 0;
  overflow: hidden;
}

.m2-referral-loading {
  min-height: 132px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #555;
}

.m2-referral-spinner {
  width: 22px;
  height: 22px;
  border: 2px solid #d9d9d9;
  border-top-color: #050505;
  border-radius: 50%;
  animation: m2-referral-spin .7s linear infinite;
}

@keyframes m2-referral-spin {
  to { transform: rotate(360deg); }
}

.m2-referral-header {
  padding: 22px 24px 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid #e5e5e5;
}

.m2-referral-header h2,
.m2-referral-modal-card h2 {
  margin: 2px 0 5px;
}

.m2-referral-header p:not(.eyebrow) {
  margin: 0;
  color: #6b6b6b;
  font-size: 13px;
}

.m2-referral-heading-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.m2-referral-state,
.m2-referral-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid #dadada;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.m2-referral-state.active {
  color: #087a36;
  border-color: #b9e9ca;
  background: #edfff4;
}

.m2-referral-state.success,
.m2-referral-status.success {
  color: #087a36;
  border-color: #b9e9ca;
  background: #edfff4;
}

.m2-referral-state.neutral {
  color: #666;
  background: #f6f6f6;
}

.m2-referral-status.pending {
  color: #835c00;
  border-color: #ead699;
  background: #fff9e7;
}

.m2-referral-status.warning {
  color: #9a4b00;
  border-color: #f2c79e;
  background: #fff4e9;
}

.m2-referral-status.working {
  color: #095ba0;
  border-color: #bad9f3;
  background: #eef8ff;
}

.m2-referral-summary {
  position: relative;
  padding: 20px 24px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 12px 24px;
  background: #fafafa;
  border-bottom: 1px solid #e5e5e5;
}

.m2-referral-progress-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.m2-referral-progress-copy > span,
.m2-referral-student > span,
.m2-referral-destination > span {
  color: #767676;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.m2-referral-progress-copy strong {
  font-size: 19px;
}

.m2-referral-progress-copy small,
.m2-referral-student small {
  color: #777;
  font-size: 11px;
}

.m2-referral-summary > b {
  align-self: center;
  min-width: 54px;
  padding: 12px 8px;
  background: #050505;
  color: #fff;
  text-align: center;
  font-size: 14px;
}

.m2-referral-progress {
  grid-column: 1 / -1;
  height: 8px;
  overflow: hidden;
  background: #e4e4e4;
}

.m2-referral-progress i {
  display: block;
  height: 100%;
  background: #13a752;
  transition: width .35s ease;
}

.m2-referral-summary dl {
  grid-column: 1 / -1;
  margin: 2px 0 0;
  display: flex;
  gap: 24px;
}

.m2-referral-summary dl div {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.m2-referral-summary dt {
  color: #777;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.m2-referral-summary dd {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
}

.m2-referral-missions {
  padding: 14px;
  display: grid;
  gap: 10px;
}

.m2-referral-mission {
  min-width: 0;
  padding: 13px 14px;
  display: grid;
  grid-template-columns: 42px minmax(180px, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  border: 1px solid #e0e0e0;
  border-left: 4px solid #d9a72a;
  background: #fff;
}

.m2-referral-mission.success { border-left-color: #17a856; }
.m2-referral-mission.warning { border-left-color: #d36a13; }
.m2-referral-mission.working { border-left-color: #287ab8; }

.m2-referral-mission-order {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: #0a0a0a;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.m2-referral-student {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.m2-referral-student strong,
.m2-referral-student small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.m2-referral-send,
.m2-referral-confirm {
  min-height: 40px;
  padding: 9px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid #0da348;
  background: #18b957;
  color: #fff;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  cursor: pointer;
}

.m2-referral-send:hover,
.m2-referral-confirm:hover { background: #0da348; }
.m2-referral-send:focus-visible,
.m2-referral-confirm:focus-visible { outline: 3px solid rgba(24,185,87,.25); outline-offset: 2px; }
.m2-referral-send svg,
.m2-referral-confirm svg { width: 17px; height: 17px; fill: currentColor; }
.m2-referral-confirm:disabled { opacity: .6; cursor: wait; }

.m2-referral-mission-error {
  grid-column: 2 / -1;
  margin: -4px 0 0;
  color: #a44800;
  font-size: 11px;
}

.m2-referral-empty {
  min-height: 112px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  text-align: center;
}

.m2-referral-empty span,
.m2-referral-quiet {
  color: #747474;
  font-size: 12px;
}

.m2-referral-empty .button { margin-top: 8px; }
.m2-referral-quiet { margin: 0; padding: 18px 24px 22px; }

.m2-referral-modal-open { overflow: hidden; }

.m2-referral-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: grid;
  place-items: center;
  padding: 20px;
  animation: m2-referral-modal-in .18s ease-out both;
}

.m2-referral-modal.is-closing { animation: m2-referral-modal-out .18s ease-in both; }

@keyframes m2-referral-modal-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes m2-referral-modal-out { from { opacity: 1; } to { opacity: 0; } }

.m2-referral-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.68);
  backdrop-filter: blur(2px);
}

.m2-referral-modal-card {
  position: relative;
  width: min(620px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 0;
  border: 1px solid #d9d9d9;
  background: #fff;
  box-shadow: 0 22px 70px rgba(0,0,0,.28);
}

.m2-referral-modal-card > header {
  padding: 20px 22px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid #e2e2e2;
}

.m2-referral-modal-card > header > button {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border: 1px solid #d5d5d5;
  background: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.m2-referral-destination {
  margin: 18px 22px 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #ccebd7;
  background: #f0fff5;
}

.m2-referral-modal-card > label {
  display: block;
  margin: 0 22px 7px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.m2-referral-modal-card textarea {
  width: calc(100% - 44px);
  min-height: 190px;
  margin: 0 22px;
  padding: 13px;
  resize: vertical;
  border: 1px solid #cfcfcf;
  border-radius: 0;
  background: #fff;
  color: #111;
  font: inherit;
  font-size: 14px;
  line-height: 1.55;
  box-sizing: border-box;
}

.m2-referral-modal-card textarea:focus { outline: 2px solid #111; outline-offset: -1px; }

.m2-referral-modal-feedback {
  min-height: 18px;
  margin: 9px 22px 4px;
  color: #666;
  font-size: 11px;
}

.m2-referral-modal-feedback.success { color: #087a36; }
.m2-referral-modal-feedback.error { color: #cb2027; }

.m2-referral-modal-card > footer {
  padding: 14px 22px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@media (max-width: 820px) {
  .m2-referral-header { padding: 18px; flex-direction: column; gap: 12px; }
  .m2-referral-heading-actions { width: 100%; justify-content: space-between; }
  .m2-referral-summary { padding: 18px; }
  .m2-referral-mission { grid-template-columns: 42px minmax(0, 1fr); gap: 10px 12px; }
  .m2-referral-status { grid-column: 1 / 2; grid-row: 2; min-height: 28px; padding: 5px 6px; white-space: normal; text-align: center; }
  .m2-referral-send { grid-column: 2 / 3; grid-row: 2; width: 100%; }
  .m2-referral-mission-error { grid-column: 1 / -1; }
}

@media (max-width: 520px) {
  .m2-referral-summary { grid-template-columns: 1fr auto; gap: 10px 12px; }
  .m2-referral-progress-copy strong { font-size: 16px; }
  .m2-referral-summary dl { gap: 12px; justify-content: space-between; }
  .m2-referral-summary dl div { flex-direction: column; gap: 1px; }
  .m2-referral-missions { padding: 10px; }
  .m2-referral-mission { padding: 11px; }
  .m2-referral-modal { padding: 0; align-items: end; }
  .m2-referral-modal-card { width: 100%; max-height: 92vh; border-width: 1px 0 0; }
  .m2-referral-modal-card > header { padding: 17px 16px 14px; }
  .m2-referral-destination { margin: 14px 16px 12px; }
  .m2-referral-modal-card > label { margin-left: 16px; margin-right: 16px; }
  .m2-referral-modal-card textarea { width: calc(100% - 32px); margin-left: 16px; margin-right: 16px; min-height: 175px; }
  .m2-referral-modal-feedback { margin-left: 16px; margin-right: 16px; }
  .m2-referral-modal-card > footer { padding: 12px 16px 18px; }
  .m2-referral-modal-card > footer > * { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .m2-referral-spinner,
  .m2-referral-modal,
  .m2-referral-modal.is-closing { animation: none; }
  .m2-referral-progress i { transition: none; }
}
