.family-management {
  display: grid;
  gap: 16px;
  margin-bottom: 18px;
}

.family-management-card { overflow: hidden; }
.family-management-card .section-head { align-items: flex-start; }
.family-management-card h2 { margin: 3px 0 0; }

.family-member-list,
.family-student-list {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

.family-member-row,
.family-student-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-2);
}

.family-member-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-bottom: 4px;
}

.family-member-row small,
.family-student-row small {
  color: var(--muted);
  line-height: 1.5;
}

.family-member-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.family-member-actions select {
  width: auto;
  min-width: 104px;
  padding: 8px 30px 8px 10px;
}

.family-inline-form,
.family-student-form {
  display: grid;
  gap: 10px;
  padding-top: 16px;
  margin-top: 16px;
  border-top: 1px solid var(--line);
}

.family-inline-form {
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.1fr) minmax(130px, .7fr) auto;
  align-items: end;
}

.family-student-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.family-inline-form .field,
.family-student-form .field { margin: 0; }

.family-form-action {
  display: flex;
  align-items: end;
}

.family-student-form .family-form-action {
  grid-column: 1 / -1;
}

.family-permission-note {
  margin: 14px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.family-readonly-note { margin-bottom: 14px; }

#family-management-notice:empty { display: none; }
#family-management-notice .notice-box,
#family-management-notice .error-box { margin-bottom: 0; }

@media (max-width: 860px) {
  .family-inline-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .family-inline-form .family-form-action { grid-column: 1 / -1; }
  .family-student-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .family-member-row,
  .family-student-row {
    align-items: stretch;
    flex-direction: column;
  }
  .family-member-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .family-member-actions select { width: 100%; }
  .family-inline-form,
  .family-student-form { grid-template-columns: 1fr; }
  .family-inline-form .family-form-action,
  .family-student-form .family-form-action { grid-column: auto; }
  .family-form-action .btn { width: 100%; }
}
